package com.corona.game;

import com.badlogic.gdx.math.Vector2;
import com.corona.Game;
import com.sun.jna.platform.win32.WinError;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Objects;
import java.util.Random;
import org.lwjgl.system.windows.User32;

/* compiled from: GenForest2.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/GenIsland1.class */
public class GenIsland1 extends Action {
    public Action.Layer layer;
    ArrayList<Vector2> freePositions;
    HashMap<Vector2, Tile> tilesToAdd;
    ArrayList<HashMap<Vector2, Tile>> interiorTilesToAdd;
    HashMap<Vector2, Pokemon> pokemonToAdd;
    ArrayList<Action> doActions;
    Vector2 bottomLeft;
    Vector2 topRight;
    Vector2 origin;
    int radius;
    ArrayList<Tile> edges;
    Random rand;
    ArrayList<Vector2> keystoneSpawns;
    public ArrayList<Vector2> noIceHerePlease;
    public ArrayList<Vector2> bottomMtnLayer;
    public HashMap<Vector2, Tile> mtnTiles;
    public int doneDesert;
    public HashMap<Pokemon, Integer> interiorPokemon;
    public ArrayList<Vector2> trapinchSpawns;
    public Vector2 randOffset;
    public static boolean donePkmnMansion = false;
    public static boolean donePkmnMansionKey = false;
    public static boolean doneRegiDungeon = false;
    public static boolean doneFossilBuilding = false;
    public static int unownCounter = 0;
    public static int numSandPits = 0;

    /* compiled from: GenForest2.java */
    /* JADX INFO: Failed to restore enum class, 'enum' modifier removed */
    /* loaded from: pokewilds.jar:com/pkmngen/game/GenIsland1$Biome.class */
    public static abstract class Biome extends Enum<Biome> {
        public abstract Tile buildTile(Vector2 vector2);
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: CFG modification limit reached, blocks count: 1058
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:66)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    public GenIsland1(Game r11, Vector2 r12, int r13) {
        /*
        // Method dump skipped, instructions count: 9597
        */
        throw new UnsupportedOperationException("Method not decompiled: com.corona.game.GenIsland1.<init>(com.corona.Game, com.badlogic.gdx.math.Vector2, int):void");
    }

    public void AddMtnLayer(HashMap<Vector2, Tile> levelTiles, HashMap<Tile, Integer> tileLevels, HashMap<Vector2, Tile> mtnTiles, int newLevel, String name, Route route, boolean iceAllowed) {
        Vector2 pos = new Vector2();
        Iterator it = new ArrayList(levelTiles.values()).iterator();
        while (it.hasNext()) {
            Tile tile = (Tile) it.next();
            pos.set(tile.position.x + 16.0f, tile.position.y);
            if (!mtnTiles.containsKey(pos)) {
                Tile nextTile = new Tile(name, "", pos.cpy(), true, route);
                nextTile.biome = "mountain";
                levelTiles.put(nextTile.position.cpy(), nextTile);
                tileLevels.put(nextTile, Integer.valueOf(newLevel));
                mtnTiles.put(nextTile.position.cpy(), nextTile);
            }
            pos.set(tile.position.x - 16.0f, tile.position.y);
            if (!mtnTiles.containsKey(pos)) {
                Tile nextTile2 = new Tile(name, "", pos.cpy(), true, route);
                nextTile2.biome = "mountain";
                levelTiles.put(nextTile2.position.cpy(), nextTile2);
                tileLevels.put(nextTile2, Integer.valueOf(newLevel));
                mtnTiles.put(nextTile2.position.cpy(), nextTile2);
            }
            pos.set(tile.position.x, tile.position.y + 16.0f);
            if (!mtnTiles.containsKey(pos)) {
                Tile nextTile3 = new Tile(name, "", pos.cpy(), true, route);
                nextTile3.biome = "mountain";
                levelTiles.put(nextTile3.position.cpy(), nextTile3);
                tileLevels.put(nextTile3, Integer.valueOf(newLevel));
                mtnTiles.put(nextTile3.position.cpy(), nextTile3);
            }
            pos.set(tile.position.x, tile.position.y - 16.0f);
            if (!mtnTiles.containsKey(pos)) {
                Tile nextTile4 = new Tile(name, "", pos.cpy(), true, route);
                nextTile4.biome = "mountain";
                levelTiles.put(nextTile4.position.cpy(), nextTile4);
                tileLevels.put(nextTile4, Integer.valueOf(newLevel));
                mtnTiles.put(nextTile4.position.cpy(), nextTile4);
            }
            pos.set(tile.position.x + 16.0f, tile.position.y + 16.0f);
            if (!mtnTiles.containsKey(pos)) {
                Tile nextTile5 = new Tile(name, "", pos.cpy(), true, route);
                nextTile5.biome = "mountain";
                levelTiles.put(nextTile5.position.cpy(), nextTile5);
                tileLevels.put(nextTile5, Integer.valueOf(newLevel));
                mtnTiles.put(nextTile5.position.cpy(), nextTile5);
            }
            pos.set(tile.position.x - 16.0f, tile.position.y + 16.0f);
            if (!mtnTiles.containsKey(pos)) {
                Tile nextTile6 = new Tile(name, "", pos.cpy(), true, route);
                nextTile6.biome = "mountain";
                levelTiles.put(nextTile6.position.cpy(), nextTile6);
                tileLevels.put(nextTile6, Integer.valueOf(newLevel));
                mtnTiles.put(nextTile6.position.cpy(), nextTile6);
            }
            pos.set(tile.position.x - 16.0f, tile.position.y - 16.0f);
            if (!mtnTiles.containsKey(pos)) {
                Tile nextTile7 = new Tile(name, "", pos.cpy(), true, route);
                nextTile7.biome = "mountain";
                levelTiles.put(nextTile7.position.cpy(), nextTile7);
                tileLevels.put(nextTile7, Integer.valueOf(newLevel));
                mtnTiles.put(nextTile7.position.cpy(), nextTile7);
            }
            pos.set(tile.position.x + 16.0f, tile.position.y - 16.0f);
            if (!mtnTiles.containsKey(pos)) {
                Tile nextTile8 = new Tile(name, "", pos.cpy(), true, route);
                nextTile8.biome = "mountain";
                levelTiles.put(nextTile8.position.cpy(), nextTile8);
                tileLevels.put(nextTile8, Integer.valueOf(newLevel));
                mtnTiles.put(nextTile8.position.cpy(), nextTile8);
            }
            levelTiles.remove(tile.position);
            if (!iceAllowed) {
                this.noIceHerePlease.add(tile.position);
            }
        }
    }

    public void ApplyBlotch(Game game, String type, Tile originTile, int maxDist, HashMap<Vector2, Tile> tilesToAdd) {
        ApplyBlotch(game, type, originTile, maxDist, tilesToAdd, 0, true);
    }

    public void ApplyBlotch(Game game, String type, Tile originTile, int maxDist, HashMap<Vector2, Tile> tilesToAdd, int isMaze, boolean doNext) {
        ApplyBlotch(game, type, originTile, maxDist, tilesToAdd, isMaze, doNext, null);
    }

    public void ApplyBlotch(Game game, String type, Tile originTile, int maxDist, HashMap<Vector2, Tile> tilesToAdd, int isMaze, boolean doNext, Route currRoute) {
        ArrayList<Tile> tileSquare;
        Tile newTile;
        int centerLevel;
        Route blotchRoute;
        int centerLevel2;
        int centerLevel3;
        Route blotchRoute2;
        HashMap<Vector2, Tile> edgeTiles = new HashMap<>();
        ArrayList<Tile> prevTiles = new ArrayList<>();
        Tile prevTile = originTile;
        edgeTiles.put(originTile.position.cpy(), originTile);
        HashMap<Vector2, Tile> grassTiles = new HashMap<>();
        if (!type.equals("beach1")) {
            isMaze = 1;
        }
        HashMap<Vector2, Tile> forestMazeTiles = new HashMap<>();
        ArrayList<Vector2> deepForestMazeTiles = new ArrayList<>();
        ArrayList<Vector2> fenceSpawns = new ArrayList<>();
        int newSize = (maxDist - this.rand.nextInt((int) Math.ceil((double) (((float) maxDist) / 4.0f)))) - (maxDist / 4);
        if (type.equals("sand_pit1")) {
            newSize = maxDist;
        }
        int doneOasis = maxDist;
        int numDarms = 10;
        Route beachRoute = null;
        Route beachRoutePlateau = null;
        Route beachRouteWater = null;
        Route deepForestRoute = null;
        if (type.equals("island")) {
            beachRoute = new Route("", 2);
            deepForestRoute = new Route("deep_forest", 33);
        } else if (type.equals("beach1")) {
            beachRoute = new Route("beach2_rocks", 22);
            beachRoutePlateau = new Route("beach2_plateau", 22);
            beachRouteWater = new Route("beach2_water", 22);
        } else if (type.equals("mtn_green1")) {
            beachRoute = new Route("mountain1_water1", 30);
        } else if (type.equals("wooded_lake1")) {
            beachRoute = new Route("wooded_lake_water1", 30);
        }
        while (!edgeTiles.isEmpty()) {
            Iterator it = new ArrayList(edgeTiles.values()).iterator();
            while (it.hasNext()) {
                Tile tile = (Tile) it.next();
                Vector2[] vector2Arr = {tile.position.cpy().add(-16.0f, 0.0f), tile.position.cpy().add(16.0f, 0.0f), tile.position.cpy().add(0.0f, 16.0f), tile.position.cpy().add(0.0f, -16.0f)};
                for (Vector2 edge : vector2Arr) {
                    float distance = edge.dst(originTile.position);
                    if (!tilesToAdd.containsKey(edge)) {
                        int putTile = this.rand.nextInt(maxDist) + ((int) distance);
                        boolean shouldPut = ((int) distance) < (7 * maxDist) / 16;
                        if (type.equals("desert")) {
                            shouldPut = ((int) distance) < (10 * maxDist) / 16;
                        } else if (type.equals("sand_pit1")) {
                            shouldPut = ((int) distance) < (10 * maxDist) / 16;
                        } else if (type.equals("graveyard1")) {
                            shouldPut = ((int) distance) < (10 * maxDist) / 16;
                        } else if (type.equals("beach1")) {
                            shouldPut = ((int) distance) < (12 * maxDist) / 16;
                        } else if (type.contains("volcano")) {
                            shouldPut = ((int) distance) < (10 * maxDist) / 16;
                        } else if (type.contains("island")) {
                            shouldPut = ((int) distance) < (8 * maxDist) / 16;
                        } else if (type.equals("wooded_lake1")) {
                            shouldPut = ((int) distance) < (12 * maxDist) / 16;
                        }
                        if (putTile < maxDist || shouldPut) {
                            if (type.equals("desert")) {
                                Tile newTile2 = new Tile("desert4", edge, true, currRoute);
                                newTile2.biome = "desert";
                                if (this.rand.nextInt(maxDist) < 6) {
                                    ApplyBlotch(game, "desert_cacti2", newTile2, 200, grassTiles, 0, false, currRoute);
                                    int nextSize = this.rand.nextInt(40) + 20;
                                    HashMap<Vector2, Tile> newTiles = new HashMap<>();
                                    ApplyBlotch(game, "desert_cacti1", newTile2, nextSize, newTiles, 0, false, currRoute);
                                    grassTiles.putAll(newTiles);
                                } else if (this.rand.nextInt(maxDist) < 3) {
                                    HashMap<Vector2, Tile> newTiles2 = new HashMap<>();
                                    ApplyBlotch(game, "desert_cacti3", newTile2, 30 + this.rand.nextInt(20), newTiles2, 0, false, currRoute);
                                    grassTiles.putAll(newTiles2);
                                } else if (this.rand.nextInt(maxDist) < 3) {
                                    newTile2 = new Tile("desert4", "cactus10", edge, true, currRoute);
                                } else if (this.rand.nextInt(maxDist) < 3) {
                                    newTile2 = new Tile("desert4", "desert4_cracked", edge, true, currRoute);
                                } else if (this.rand.nextInt(maxDist) < 3) {
                                    numSandPits = 0;
                                    newTile2 = new Tile("desert2_trapinch_spawn", edge, true, currRoute);
                                    HashMap<Vector2, Tile> newTiles3 = new HashMap<>();
                                    ApplyBlotch(game, "sand_pit1", newTile2, 45, newTiles3, 0, true, new Route("sand_pit1", 44));
                                    grassTiles.putAll(newTiles3);
                                } else {
                                    Vector2 rotate = edge.cpy().rotateDeg(45.0f);
                                    if ((Math.abs((float) (Math.floorMod((int) ((rotate.x / 30.0f) - (rotate.y / 30.0f)), 14) - 7)) + Math.abs((float) (Math.floorMod((int) (rotate.y / 30.0f), 14) - 7))) * ((Math.abs((float) (Math.floorMod((int) (rotate.x / 30.0f), 20) - 10)) + Math.abs((float) (Math.floorMod((int) (rotate.y / 30.0f), 20) - 10))) / 5.0f) > 45.0f) {
                                        String nameUpper = "";
                                        if (this.rand.nextInt(10) < 5) {
                                            nameUpper = "berrytree_rawst_full";
                                        }
                                        newTile2 = new Tile("desert4", nameUpper, edge, true, currRoute);
                                    }
                                }
                                tilesToAdd.put(newTile2.position.cpy(), newTile2);
                                edgeTiles.put(newTile2.position.cpy(), newTile2);
                                if (this.doneDesert < 2) {
                                    this.doneDesert = 2;
                                }
                                if (doneOasis > 0) {
                                    doneOasis--;
                                }
                            } else if (type.equals("island")) {
                                Tile newTile3 = new Tile("sand1", edge, true, beachRoute);
                                int isRock = this.rand.nextInt(maxDist) + ((int) distance);
                                if (isRock > maxDist + (maxDist / 2)) {
                                    Route tempRoute = null;
                                    if (this.rand.nextInt(3) == 2) {
                                        tempRoute = new Route("", 11);
                                        String[] pokemon = {"shellder", "krabby", "staryu", "dwebble"};
                                        tempRoute.storedPokemon.add(new Pokemon(pokemon[this.rand.nextInt(pokemon.length)], 11 + this.rand.nextInt(3)));
                                    }
                                    newTile3 = new Tile("rock1", edge, true, tempRoute);
                                }
                                int isGrass = this.rand.nextInt(maxDist / 8) + ((int) distance);
                                if (distance < ((float) ((8 * maxDist) / 16))) {
                                    if (((int) distance) < (3 * maxDist) / 8) {
                                        if (this.rand.nextInt(24) == 0) {
                                            newTile3 = new Tile("flower4", edge, true, currRoute);
                                        } else {
                                            newTile3 = new Tile("green1", edge, true, currRoute);
                                        }
                                    } else if (distance > ((float) ((15 * maxDist) / 32))) {
                                        Vector2 rotate2 = edge.cpy().rotateDeg(-15.0f);
                                        int offsetY = (((int) Math.abs(rotate2.y / 8.0f)) % 14) - 7;
                                        if ((Math.abs(((((int) Math.abs(rotate2.x / 8.0f)) - (offsetY * 2)) % 14) - 7) + Math.abs(offsetY)) * ((Math.abs((((int) Math.abs(rotate2.x / 8.0f)) % 20) - 10) + Math.abs((((int) Math.abs(rotate2.y / 8.0f)) % 20) - 10)) / 5) > 6) {
                                            newTile3 = new Tile("green1", edge, true, currRoute);
                                        }
                                    } else {
                                        newTile3 = new Tile("green1", edge, true, currRoute);
                                    }
                                    Vector2 rotate3 = edge.cpy().rotateDeg(45.0f);
                                    newTile = newTile3;
                                    if ((Math.abs((float) ((((int) Math.abs((rotate3.x / 30.0f) - (rotate3.y / 30.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate3.y / 30.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate3.x / 30.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate3.y / 30.0f)) % 20) - 10))) / 5.0f) > 42.0f) {
                                        String nameUpper2 = "";
                                        Route tempRoute2 = currRoute;
                                        if (this.rand.nextInt(10) < 5) {
                                            nameUpper2 = "berrytree_persim_full";
                                            if (this.rand.nextInt(6) == 0) {
                                                tempRoute2 = new Route("", 22);
                                                String[] pokemon2 = {"sudowoodo"};
                                                tempRoute2.storedPokemon.add(new Pokemon(pokemon2[this.rand.nextInt(pokemon2.length)], 20 + this.rand.nextInt(4)));
                                            }
                                        }
                                        newTile = new Tile(newTile3.name, nameUpper2, edge, true, tempRoute2);
                                    }
                                } else if (isRock <= maxDist + (maxDist / 2) && isGrass < maxDist - (maxDist / 4) && this.rand.nextInt(40) == 0) {
                                    Route tempRoute3 = new Route("", 11);
                                    int randInt = this.rand.nextInt(5);
                                    if (randInt == 4) {
                                        tempRoute3.storedPokemon.add(new Pokemon("Exeggutor", 10 + this.rand.nextInt(4)));
                                    } else if (randInt > 1) {
                                        tempRoute3.storedPokemon.add(new Pokemon("Exeggcute", 10 + this.rand.nextInt(4)));
                                    }
                                    if (this.rand.nextInt(2) == 0) {
                                        ApplyBlotch(game, "grass_sand", newTile3, 35, grassTiles, 0, false, new Route("beach1", 3));
                                    }
                                    if (this.rand.nextInt(10) == 0) {
                                        int i = unownCounter;
                                        unownCounter = i + 1;
                                        newTile = new TrainerTipsTile(edge, tempRoute3, i % 64 == 0, "");
                                    } else {
                                        newTile = new Tile("tree5", edge, true, tempRoute3);
                                    }
                                } else if (isRock <= maxDist + (maxDist / 2) && isGrass < maxDist - (maxDist / 4) && this.rand.nextInt(200) == 0) {
                                    newTile = new Tile(newTile3.name, "pokeball1", edge, true, currRoute);
                                } else if (isRock > maxDist + (maxDist / 2) || isGrass >= maxDist - (maxDist / 4) || this.rand.nextInt(450) != 0) {
                                    Vector2 rotate4 = edge.cpy().rotateDeg(45.0f);
                                    newTile = newTile3;
                                    if ((Math.abs((float) ((((int) Math.abs((rotate4.x / 30.0f) - (rotate4.y / 30.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate4.y / 30.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate4.x / 30.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate4.y / 30.0f)) % 20) - 10))) / 5.0f) > 39.0f) {
                                        String nameUpper3 = "";
                                        Route tempRoute4 = currRoute;
                                        if (this.rand.nextInt(10) < 5) {
                                            nameUpper3 = "berrytree_pecha_full";
                                            if (this.rand.nextInt(6) == 0) {
                                                tempRoute4 = new Route("", 22);
                                                String[] pokemon3 = {"sudowoodo"};
                                                tempRoute4.storedPokemon.add(new Pokemon(pokemon3[this.rand.nextInt(pokemon3.length)], 20 + this.rand.nextInt(4)));
                                            }
                                        }
                                        newTile = new Tile(newTile3.name, nameUpper3, edge, true, tempRoute4);
                                    }
                                } else {
                                    if (maxDist > 300) {
                                        centerLevel3 = 30;
                                    } else {
                                        centerLevel3 = 15;
                                    }
                                    int level = (int) (((float) centerLevel3) * (1.0f - (distance / ((float) ((2 * maxDist) / 5)))));
                                    if (level < 4) {
                                        level = 4;
                                    }
                                    if (((int) distance) < (2 * maxDist) / 8 && maxDist > 600) {
                                        blotchRoute2 = new Route("deep_forest", level);
                                    } else if (((int) distance) < (3 * maxDist) / 8) {
                                        blotchRoute2 = new Route("forest1", level);
                                    } else {
                                        blotchRoute2 = new Route("savanna1", level);
                                    }
                                    Pokemon pokemon4 = new Pokemon(blotchRoute2.allowedPokemon().get(this.rand.nextInt(blotchRoute2.allowedPokemon().size())), blotchRoute2.level + this.rand.nextInt(3), Pokemon.Generation.CRYSTAL);
                                    pokemon4.position = edge.cpy();
                                    pokemon4.mapTiles = game.map.overworldTiles;
                                    if (pokemon4.specie.name.toLowerCase(Locale.ROOT).equals("ekans") || pokemon4.specie.name.toLowerCase(Locale.ROOT).equals("pidgey") || pokemon4.specie.name.toLowerCase(Locale.ROOT).equals("spearow") || pokemon4.specie.name.toLowerCase(Locale.ROOT).equals("rattata")) {
                                        pokemon4.happiness = 0;
                                    }
                                    Objects.requireNonNull(pokemon4);
                                    pokemon4.standingAction = new Pokemon.Standing();
                                    this.pokemonToAdd.put(pokemon4.position.cpy(), pokemon4);
                                    newTile = newTile3;
                                    if (GenForest2.mates2.containsKey(pokemon4.specie.name)) {
                                        String oppGender = pokemon4.gender.equals("male") ? "female" : "male";
                                        Pokemon mate = new Pokemon(GenForest2.mates2.get(pokemon4.specie.name), pokemon4.level);
                                        mate.gender = oppGender;
                                        mate.position = pokemon4.position.cpy().add(16.0f, 0.0f);
                                        mate.mapTiles = game.map.overworldTiles;
                                        Objects.requireNonNull(mate);
                                        mate.standingAction = new Pokemon.Standing();
                                        this.pokemonToAdd.put(mate.position.cpy(), mate);
                                        newTile = newTile3;
                                    }
                                }
                                if (distance < ((float) (maxDist / 4)) && maxDist > 300 && this.rand.nextInt(WinError.ERROR_PAGE_FAULT_GUARD_PAGE) == 0) {
                                    if (maxDist > 300) {
                                        centerLevel2 = 50;
                                    } else {
                                        centerLevel2 = 15;
                                    }
                                    int level2 = (int) (((float) centerLevel2) * (1.0f - (distance / ((float) ((2 * maxDist) / 5)))));
                                    if (level2 < 4) {
                                        level2 = 4;
                                    }
                                    Pokemon pokemon5 = new Pokemon((String) new ArrayList(GenForest2.mates.keySet()).get(Game.rand.nextInt(GenForest2.mates.keySet().size())), level2);
                                    pokemon5.position = edge.cpy();
                                    pokemon5.mapTiles = game.map.overworldTiles;
                                    Objects.requireNonNull(pokemon5);
                                    pokemon5.standingAction = new Pokemon.Standing();
                                    this.pokemonToAdd.put(pokemon5.position.cpy(), pokemon5);
                                    String oppGender2 = pokemon5.gender.equals("male") ? "female" : "male";
                                    Pokemon mate2 = new Pokemon(GenForest2.mates.get(pokemon5.specie.name), pokemon5.level);
                                    mate2.gender = oppGender2;
                                    mate2.position = pokemon5.position.cpy().add(16.0f, 0.0f);
                                    mate2.mapTiles = game.map.overworldTiles;
                                    Objects.requireNonNull(mate2);
                                    mate2.standingAction = new Pokemon.Standing();
                                    this.pokemonToAdd.put(mate2.position.cpy(), mate2);
                                }
                                if (isMaze == 0) {
                                    if (this.rand.nextInt(maxDist / 4) + ((int) distance) < (1 * maxDist) / 3 && newTile.position.y % 32.0f == 0.0f) {
                                        newTile = new Tile("tree2", edge);
                                    }
                                } else if (((int) distance) + this.rand.nextInt((maxDist / 14) + 1) < (8 * maxDist) / 16) {
                                    forestMazeTiles.put(newTile.position.cpy(), newTile);
                                }
                                int grassBlotchHere = this.rand.nextInt(maxDist / 4) + ((int) distance);
                                int grassBlotchHere2 = this.rand.nextInt(maxDist);
                                int grassBlotchHere3 = this.rand.nextInt(maxDist);
                                if (((int) distance) < maxDist - (maxDist / 5) && grassBlotchHere < (3 * maxDist) / 7 && grassBlotchHere2 < maxDist / 4 && (maxDist < 300 || grassBlotchHere3 < maxDist / 8)) {
                                    int nextSize2 = (int) Math.ceil((double) (((float) maxDist) / 6.0f));
                                    if (maxDist > 300) {
                                        nextSize2 = (int) Math.ceil((double) (((float) maxDist) / 12.0f));
                                    }
                                    if (maxDist > 1000) {
                                        nextSize2 = (int) Math.ceil((double) (((float) maxDist) / 32.0f));
                                    }
                                    if (maxDist > 300) {
                                        centerLevel = 30;
                                    } else {
                                        centerLevel = 15;
                                    }
                                    int level3 = (int) (((float) centerLevel) * (1.0f - (distance / ((float) ((2 * maxDist) / 5)))));
                                    if (level3 < 4) {
                                        level3 = 4;
                                    }
                                    if (((int) distance) < (2 * maxDist) / 8 && maxDist > 600) {
                                        blotchRoute = deepForestRoute;
                                    } else if (((int) distance) < (4 * maxDist) / 8) {
                                        blotchRoute = new Route("forest1", level3);
                                    } else {
                                        blotchRoute = new Route("savanna1", level3);
                                    }
                                    ApplyBlotch(game, "grass", newTile, nextSize2, grassTiles, 0, false, blotchRoute);
                                }
                                if (((int) distance) < (2 * maxDist) / 8 && maxDist > 300) {
                                    newTile.biome = "deep_forest";
                                    deepForestMazeTiles.add(newTile.position.cpy());
                                }
                                tilesToAdd.put(newTile.position.cpy(), newTile);
                                edgeTiles.put(newTile.position.cpy(), newTile);
                            } else if (type.equals("grass")) {
                                String name = "grass2";
                                if (currRoute.name.contains("savanna") || currRoute.name.contains("oasis")) {
                                    name = "grass4";
                                }
                                Tile newTile4 = new Tile(name, edge, false, currRoute);
                                if (((int) distance) < (3 * maxDist) / 8 && maxDist > 300) {
                                    newTile4.biome = "deep_forest";
                                }
                                tilesToAdd.put(newTile4.position.cpy(), newTile4);
                                edgeTiles.put(newTile4.position.cpy(), newTile4);
                            } else if (type.equals("grass_sand")) {
                                Tile newTile5 = new Tile("grass_sand1", edge, false, currRoute);
                                newTile5.biome = originTile.biome;
                                tilesToAdd.put(newTile5.position.cpy(), newTile5);
                                edgeTiles.put(newTile5.position.cpy(), newTile5);
                            } else if (type.equals("grass_desert1")) {
                                Tile newTile6 = new Tile("desert4", edge);
                                if (distance < ((float) ((2 * maxDist) / 3))) {
                                    newTile6 = new Tile("grass_sand3", edge, true, currRoute);
                                }
                                tilesToAdd.put(newTile6.position.cpy(), newTile6);
                                edgeTiles.put(newTile6.position.cpy(), newTile6);
                            } else if (type.contains("grass_")) {
                                Tile newTile7 = new Tile(type, edge, false, currRoute);
                                tilesToAdd.put(newTile7.position.cpy(), newTile7);
                                edgeTiles.put(newTile7.position.cpy(), newTile7);
                            } else if (type.equals("sand_pit1")) {
                                Tile newTile8 = new Tile("desert4", edge);
                                if (distance < ((float) ((2 * maxDist) / 3))) {
                                    newTile8 = new Tile("desert2", edge, true, currRoute);
                                    if (this.rand.nextInt(256) < 8) {
                                        this.trapinchSpawns.add(edge.cpy());
                                    }
                                }
                                tilesToAdd.put(newTile8.position.cpy(), newTile8);
                                edgeTiles.put(newTile8.position.cpy(), newTile8);
                            } else if (type.equals("ruins1_upper")) {
                                Tile newTile9 = new Tile("desert4", edge);
                                if (distance < ((float) ((2 * maxDist) / 5))) {
                                    if (this.rand.nextInt(maxDist) + ((int) distance) < maxDist) {
                                        newTile9 = new Tile("ruins1", edge, true, currRoute);
                                    } else if (edge.y % 32.0f == 0.0f && edge.x % 64.0f == 0.0f) {
                                        newTile9 = new Tile("ruins1_pillar1", edge, true, currRoute);
                                    }
                                } else if (distance < ((float) ((3 * maxDist) / 5))) {
                                    if (this.rand.nextInt(20) > 10 && edge.y % 32.0f == 0.0f && edge.x % 64.0f == 0.0f) {
                                        newTile9 = this.rand.nextInt(20) > 9 ? new Tile("ruins1_pillar1_broken", edge, true, currRoute) : new Tile("ruins1_pillar1", edge, true, currRoute);
                                    } else if (this.rand.nextInt(20) > numDarms && edge.y % 32.0f == 0.0f && edge.x % 32.0f == 0.0f) {
                                        Pokemon darmanitan = new Pokemon("darmanitanzen", 35, Pokemon.Generation.CRYSTAL);
                                        darmanitan.position = newTile9.position.cpy();
                                        darmanitan.mapTiles = game.map.overworldTiles;
                                        Objects.requireNonNull(darmanitan);
                                        darmanitan.standingAction = new Pokemon.Standing();
                                        this.pokemonToAdd.put(darmanitan.position.cpy(), darmanitan);
                                        numDarms++;
                                    }
                                } else if (this.rand.nextInt(10) > 4) {
                                    newTile9 = new Tile("grass_sand3", edge, true, currRoute);
                                    HashMap<Vector2, Tile> newTiles4 = new HashMap<>();
                                    ApplyBlotch(game, "grass_desert1", newTile9, 95, newTiles4, 0, true, currRoute);
                                    grassTiles.putAll(newTiles4);
                                    if (this.rand.nextInt(2) > 0) {
                                        newTile9 = new Tile("grass_sand3", edge, true, currRoute);
                                        HashMap<Vector2, Tile> newTiles5 = new HashMap<>();
                                        if (this.rand.nextInt(2) > 0) {
                                            ApplyBlotch(game, "desert_cacti1", newTile9, this.rand.nextInt(40) + 20, newTiles5, 0, true, currRoute);
                                        } else {
                                            ApplyBlotch(game, "desert_cacti3", newTile9, 30 + this.rand.nextInt(20), newTiles5, 0, false, currRoute);
                                        }
                                        grassTiles.putAll(newTiles5);
                                    }
                                }
                                tilesToAdd.put(newTile9.position.cpy(), newTile9);
                                edgeTiles.put(newTile9.position.cpy(), newTile9);
                            } else if (type.equals("ruins1_upper2")) {
                                Tile newTile10 = new Tile("desert4", edge);
                                if (this.rand.nextInt(3) > 0) {
                                    newTile10 = new Tile("ruins1_NSEW", edge, true, currRoute);
                                }
                                tilesToAdd.put(newTile10.position.cpy(), newTile10);
                                edgeTiles.put(newTile10.position.cpy(), newTile10);
                            } else if (type.equals("pond1")) {
                                Tile newTile11 = new Tile("water2", edge, true, currRoute);
                                tilesToAdd.put(newTile11.position.cpy(), newTile11);
                                edgeTiles.put(newTile11.position.cpy(), newTile11);
                            } else if (type.equals("oasis1")) {
                                Tile newTile12 = new Tile("sand1", "", edge, true, currRoute);
                                if (this.rand.nextInt(maxDist / 8) + ((int) distance) < (1 * maxDist) / 2) {
                                    if (((int) distance) >= (3 * maxDist) / 8) {
                                        newTile12 = new Tile("green1", edge, true, currRoute);
                                    } else if (this.rand.nextInt(24) == 0) {
                                        newTile12 = new Tile("flower4", edge, true, currRoute);
                                    } else {
                                        newTile12 = new Tile("green1", edge, true, currRoute);
                                    }
                                }
                                boolean putGrass = this.rand.nextInt(90) < 1;
                                if (distance < ((float) (maxDist / 2))) {
                                    putGrass = this.rand.nextInt(40) < 1;
                                }
                                boolean putRock = false;
                                if (distance > ((float) (maxDist / 2))) {
                                    putRock = this.rand.nextInt(10) < 1;
                                }
                                if (putGrass) {
                                    ApplyBlotch(game, "grass", newTile12, 40, grassTiles, 0, false, new Route("oasis1", 30));
                                } else if (this.rand.nextInt(10) < 1) {
                                    Route tempRoute5 = new Route("", 22);
                                    tempRoute5.name = "oasis1";
                                    if (this.rand.nextInt(2) == 0) {
                                        String[] pokemon6 = {"aexeggutor"};
                                        tempRoute5.storedPokemon.add(new Pokemon(pokemon6[this.rand.nextInt(pokemon6.length)], tempRoute5.level, Pokemon.Generation.CRYSTAL));
                                    }
                                    newTile12 = new Tile("tree5", edge, true, tempRoute5);
                                } else if (this.rand.nextInt(110) < 1) {
                                    newTile12 = new Tile("green1", "aloe_large1", edge, true, currRoute);
                                } else if (putRock) {
                                    Route tempRoute6 = new Route("", 22);
                                    tempRoute6.name = "oasis1";
                                    if (this.rand.nextInt(2) == 0) {
                                        String[] pokemon7 = {"shellder", "krabby", "staryu", "dwebble"};
                                        tempRoute6.storedPokemon.add(new Pokemon(pokemon7[this.rand.nextInt(pokemon7.length)], tempRoute6.level, Pokemon.Generation.CRYSTAL));
                                    }
                                    newTile12 = new Tile(newTile12.name, "rock1_color", edge.cpy(), true, tempRoute6);
                                }
                                tilesToAdd.put(newTile12.position.cpy(), newTile12);
                                edgeTiles.put(newTile12.position.cpy(), newTile12);
                            } else if (type.equals("desert_cacti1")) {
                                Tile newTile13 = new Tile("desert4", edge);
                                boolean doCactus = true;
                                if (distance > 0.0f) {
                                    doCactus = this.rand.nextInt((int) distance) < maxDist / 8;
                                }
                                if (doCactus) {
                                    Route tempRoute7 = null;
                                    if (this.rand.nextInt(2) == 0) {
                                        String[] pokemon8 = {"maractus"};
                                        int randInt2 = this.rand.nextInt(pokemon8.length);
                                        tempRoute7 = new Route("", 22);
                                        tempRoute7.storedPokemon.add(new Pokemon(pokemon8[randInt2], tempRoute7.level, Pokemon.Generation.CRYSTAL));
                                    }
                                    if (distance < ((float) (maxDist / 4))) {
                                        newTile13 = new Tile("cactus2", edge, true, tempRoute7);
                                    } else if (!(newTile13.position.x == originTile.position.x && newTile13.position.y == originTile.position.y + 16.0f)) {
                                        newTile13 = new Tile("cactus1", edge, true, tempRoute7);
                                    }
                                }
                                tilesToAdd.put(newTile13.position.cpy(), newTile13);
                                edgeTiles.put(newTile13.position.cpy(), newTile13);
                            } else if (type.equals("desert_cacti3")) {
                                Tile newTile14 = new Tile("desert4", edge, true, currRoute);
                                boolean doCactus2 = true;
                                if (distance > 0.0f) {
                                    doCactus2 = this.rand.nextInt((int) distance) < maxDist / 8;
                                }
                                if (doCactus2) {
                                    if (distance < ((float) (maxDist / 4))) {
                                        newTile14 = new Tile("desert6", "cactus9", edge, true, null);
                                    } else {
                                        newTile14 = new Tile("desert6", "cactus8", edge, true, null);
                                    }
                                }
                                tilesToAdd.put(newTile14.position.cpy(), newTile14);
                                edgeTiles.put(newTile14.position.cpy(), newTile14);
                            } else if (type.equals("desert_cacti4")) {
                                Tile newTile15 = new Tile("desert4", edge, true, currRoute);
                                if (this.rand.nextInt((int) (((float) maxDist) - distance)) < maxDist) {
                                    if (distance >= ((float) (maxDist / 4))) {
                                        newTile15 = new Tile("desert6", "cactus7", edge, true, null);
                                    } else if (this.rand.nextInt(2) == 1) {
                                        newTile15 = new Tile("desert6", "cactus7", edge, true, null);
                                    }
                                }
                                tilesToAdd.put(newTile15.position.cpy(), newTile15);
                                edgeTiles.put(newTile15.position.cpy(), newTile15);
                            } else if (type.equals("desert_cacti2")) {
                                Tile newTile16 = new Tile("desert4", edge, true, currRoute);
                                if (distance >= ((float) ((2 * maxDist) / 7)) && distance < ((float) ((5 * maxDist) / 7))) {
                                }
                                tilesToAdd.put(newTile16.position.cpy(), newTile16);
                                edgeTiles.put(newTile16.position.cpy(), newTile16);
                            } else if (type.equals("beach1")) {
                                String name2 = "sand4_tidalwater";
                                String nameUpper4 = "";
                                Route tileRoute = currRoute;
                                if (distance > ((float) ((5 * maxDist) / 9))) {
                                    name2 = "water2";
                                    tileRoute = beachRouteWater;
                                }
                                Vector2 rotate5 = edge.cpy().rotateDeg(45.0f);
                                int offset1 = Math.abs((((int) Math.abs(rotate5.x / ((float) 16))) % 14) - 7) + Math.abs((((int) Math.abs(rotate5.y / ((float) 16))) % 14) - 7);
                                int offset2 = Math.abs((((int) Math.abs(rotate5.x / ((float) 16))) % 20) - 10) + Math.abs((((int) Math.abs(rotate5.y / ((float) 16))) % 20) - 10);
                                int offset3 = (Math.abs((((int) Math.abs(rotate5.x / ((float) 16))) % 60) - 30) + Math.abs((((int) Math.abs(rotate5.y / ((float) 16))) % 60) - 30)) * 2;
                                if (offset1 * (offset2 / 5) * offset3 <= 320) {
                                    name2 = "mountain4";
                                    if (offset1 < 2) {
                                        name2 = "water2";
                                    } else if (offset2 < 7) {
                                        nameUpper4 = "stalagmite1";
                                    }
                                    if (offset3 >= 30) {
                                        tileRoute = beachRoute;
                                    } else {
                                        tileRoute = beachRoutePlateau;
                                    }
                                }
                                Vector2 rotate6 = edge.cpy().rotateDeg(45.0f);
                                int offset12 = Math.abs((((int) Math.abs(rotate6.x / ((float) 16))) % 14) - 7) + Math.abs((((int) Math.abs(rotate6.y / ((float) 16))) % 14) - 7);
                                int offset22 = (Math.abs((((int) Math.abs(rotate6.x / ((float) 16))) % 20) - 10) + Math.abs((((int) Math.abs(rotate6.y / ((float) 16))) % 20) - 10)) / 5;
                                if (offset12 * offset22 > 16) {
                                    name2 = "water2";
                                } else if (!name2.equals("water2") && !name2.equals("mountain4") && offset12 * offset22 < 13 && offset12 * offset22 > 9) {
                                    name2 = name2 + "_puddle1";
                                }
                                if (!name2.contains("sand4") || !nameUpper4.equals("")) {
                                    if (name2.equals("mountain4") && nameUpper4.equals("")) {
                                        int rate = 5;
                                        if (offset3 < 30) {
                                            rate = 20;
                                        }
                                        if (this.rand.nextInt(rate) == 0) {
                                            nameUpper4 = "rock5";
                                        } else if (this.rand.nextInt(rate) == 0) {
                                            nameUpper4 = "rock1_color";
                                        }
                                    }
                                } else if (this.rand.nextInt(50) == 0) {
                                    nameUpper4 = "tree6";
                                } else if (this.rand.nextInt(50) == 0) {
                                    name2 = "rock1";
                                }
                                Tile newTile17 = new Tile(name2, nameUpper4, edge, true, tileRoute);
                                newTile17.biome = "beach";
                                if (this.rand.nextInt(70) < 1) {
                                    ApplyBlotch(game, "grass_sand", newTile17, 40, grassTiles, 0, false, currRoute);
                                }
                                tilesToAdd.put(newTile17.position.cpy(), newTile17);
                                edgeTiles.put(newTile17.position.cpy(), newTile17);
                            } else if (type.equals("savanna1")) {
                                String name3 = "green_savanna1";
                                String nameUpper5 = "";
                                Route tempRoute8 = currRoute;
                                Vector2 rotate7 = edge.cpy().rotateDeg(-15.0f);
                                int offsetY2 = (((int) Math.abs(rotate7.y / ((float) 8))) % 14) - 7;
                                int offset13 = Math.abs(((((int) Math.abs(rotate7.x / ((float) 8))) - (offsetY2 * 2)) % 14) - 7) + Math.abs(offsetY2);
                                int offset23 = Math.abs((((int) Math.abs(rotate7.x / ((float) 8))) % 20) - 10) + Math.abs((((int) Math.abs(rotate7.y / ((float) 8))) % 20) - 10);
                                if (offset13 * (offset23 / 5) > 6) {
                                    name3 = "green_savanna3";
                                    if (this.rand.nextInt(5) == 0) {
                                        if (edge.x % 32.0f == 0.0f) {
                                            name3 = "green_savanna4";
                                        } else {
                                            name3 = "green_savanna5";
                                        }
                                    }
                                } else if (offset13 * offset23 < 8) {
                                    name3 = "sand1";
                                }
                                Vector2 rotate8 = edge.cpy().rotate(0.0f);
                                int offset32 = (Math.abs((((int) Math.abs(rotate8.y / ((float) 12))) % 34) - 12) + Math.abs((((int) Math.abs(rotate8.y / ((float) 12))) % 60) - 30)) / 2;
                                int offset14 = Math.abs((((int) Math.abs((rotate8.x / ((float) 12)) - ((float) offset32))) % 14) - 7) + Math.abs((((int) Math.abs(rotate8.y / ((float) 12))) % 14) - 7);
                                int offset24 = Math.abs((((int) Math.abs((rotate8.x / ((float) 12)) - ((float) offset32))) % 20) - 10) + Math.abs((((int) Math.abs(rotate8.y / ((float) 12))) % 20) - 10);
                                if (offset14 * (offset24 / 5) > 16) {
                                    nameUpper5 = "grass_savanna1";
                                } else if (offset14 * (offset24 / 5) > 14) {
                                    nameUpper5 = "grass_savanna2";
                                } else if (offset14 * offset24 < 1) {
                                    nameUpper5 = "tree_savanna1";
                                } else if (this.rand.nextInt(50) == 0) {
                                    nameUpper5 = "bush_savanna1";
                                } else {
                                    Vector2 rotate9 = edge.cpy().rotateDeg(45.0f);
                                    if ((Math.abs((((int) Math.abs((rotate9.x / ((float) 16)) - (rotate9.y / ((float) 16)))) % 14) - 7) + Math.abs((((int) Math.abs(rotate9.y / ((float) 16))) % 14) - 7)) * ((Math.abs((((int) Math.abs(rotate9.x / ((float) 16))) % 20) - 10) + Math.abs((((int) Math.abs(rotate9.y / ((float) 16))) % 20) - 10)) / 5) > 36 && this.rand.nextInt(10) < 4) {
                                        nameUpper5 = "berrytree_cheri_full";
                                        if (this.rand.nextInt(6) == 0) {
                                            tempRoute8 = new Route("", 22);
                                            String[] pokemon9 = {"sudowoodo"};
                                            tempRoute8.storedPokemon.add(new Pokemon(pokemon9[this.rand.nextInt(pokemon9.length)], 20 + this.rand.nextInt(4)));
                                        }
                                    }
                                }
                                Tile newTile18 = new Tile(name3, nameUpper5, edge, true, tempRoute8);
                                newTile18.biome = "savanna";
                                tilesToAdd.put(newTile18.position.cpy(), newTile18);
                                edgeTiles.put(newTile18.position.cpy(), newTile18);
                            } else if (type.equals("graveyard1")) {
                                if (!riverContains(tile.position)) {
                                    String name4 = "green12";
                                    String nameUpper6 = "";
                                    Route tempRoute9 = currRoute;
                                    Vector2 rotate10 = edge.cpy().rotateDeg(-15.0f);
                                    int offsetY3 = (((int) Math.abs(rotate10.y / 8.0f)) % 14) - 7;
                                    int offset15 = Math.abs(((((int) Math.abs(rotate10.x / 8.0f)) - (offsetY3 * 2)) % 14) - 7) + Math.abs(offsetY3);
                                    if (offset15 * ((Math.abs((((int) Math.abs(rotate10.x / 8.0f)) % 20) - 10) + Math.abs((((int) Math.abs(rotate10.y / 8.0f)) % 20) - 10)) / 5) > 6) {
                                        name4 = "green11";
                                        if (this.rand.nextInt(5) == 0) {
                                            name4 = this.rand.nextBoolean() ? "green10" : "green9";
                                        }
                                    } else if (offset15 < 2) {
                                        if (this.rand.nextInt(256) < 80) {
                                            name4 = "flower5";
                                        }
                                    } else if (this.rand.nextInt(15) == 0) {
                                        name4 = "flower5";
                                    }
                                    if (!name4.equals("flower5") && this.rand.nextInt(110) == 0) {
                                        int randNum = this.rand.nextInt(3);
                                        if (randNum == 0) {
                                            nameUpper6 = "tree8";
                                            if (this.rand.nextInt(3) == 2) {
                                                tempRoute9 = new Route("", 30);
                                                String[] pokemon10 = {"trevenant"};
                                                tempRoute9.storedPokemon.add(new Pokemon(pokemon10[this.rand.nextInt(pokemon10.length)], tempRoute9.level + this.rand.nextInt(4)));
                                            }
                                        } else if (randNum == 1) {
                                            nameUpper6 = "berrytree_chesto_full";
                                            if (this.rand.nextInt(6) == 0) {
                                                tempRoute9 = new Route("", 22);
                                                String[] pokemon11 = {"sudowoodo"};
                                                tempRoute9.storedPokemon.add(new Pokemon(pokemon11[this.rand.nextInt(pokemon11.length)], 20 + this.rand.nextInt(4)));
                                            }
                                        } else {
                                            nameUpper6 = "tree9";
                                            if (this.rand.nextInt(3) == 2) {
                                                tempRoute9 = new Route("", 30);
                                                String[] pokemon12 = {"phantump"};
                                                tempRoute9.storedPokemon.add(new Pokemon(pokemon12[this.rand.nextInt(pokemon12.length)], 10 + this.rand.nextInt(4)));
                                            }
                                        }
                                    }
                                    if ((edge.y / 16.0f) % 2.0f == ((float) ((int) (((edge.y / 32.0f) % 11.0f) / 5.0f))) && (edge.x / 16.0f) % 2.0f == ((float) ((int) ((((edge.x / 16.0f) + (edge.y / 2.0f)) % 13.0f) / 5.0f)))) {
                                        Vector2 rotate11 = edge.cpy().rotateDeg(0.0f);
                                        offset15 = Math.abs((((int) Math.abs((rotate11.x / ((float) 16)) - (rotate11.y / ((float) 16)))) % 14) - 7) + Math.abs((((int) Math.abs(rotate11.y / ((float) 16))) % 14) - 7);
                                        if (offset15 * ((Math.abs((((int) Math.abs(rotate11.x / ((float) 16))) % 20) - 10) + Math.abs((((int) Math.abs(rotate11.y / ((float) 16))) % 20) - 10)) / 5) > 9) {
                                            name4 = "green12";
                                            nameUpper6 = "gravestone2";
                                        }
                                    }
                                    Tile newTile19 = new Tile(name4, nameUpper6, edge, true, tempRoute9);
                                    boolean putGrass2 = this.rand.nextInt(90) < 1;
                                    if (distance > ((float) (maxDist / 2))) {
                                        putGrass2 = this.rand.nextInt(40) < 1;
                                    }
                                    if (putGrass2) {
                                        ApplyBlotch(game, "grass_graveyard1", newTile19, 40, grassTiles, 0, false, currRoute);
                                    }
                                    newTile19.biome = "graveyard";
                                    tilesToAdd.put(newTile19.position.cpy(), newTile19);
                                    edgeTiles.put(newTile19.position.cpy(), newTile19);
                                    if (offset15 < 1) {
                                        fenceSpawns.add(edge.cpy());
                                    }
                                }
                            } else if (type.equals("mtn_snow1")) {
                                Route tempRoute10 = currRoute;
                                String name5 = "snow6";
                                if (edge.x % 32.0f == edge.y % 32.0f) {
                                    name5 = "snow5";
                                }
                                String nameUpper7 = "";
                                Vector2 rotate12 = edge.cpy().rotate(-15.0f);
                                float offsetY4 = (float) ((((int) Math.abs(rotate12.y / 8.0f)) % 14) - 7);
                                if ((Math.abs(((((float) ((int) Math.abs(rotate12.x / 8.0f))) - (offsetY4 * 2.0f)) % 14.0f) - 7.0f) + Math.abs(offsetY4)) * ((((float) Math.abs((((int) Math.abs(rotate12.x / 8.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate12.y / 8.0f)) % 20) - 10))) / 5.0f) > 16.0f) {
                                    name5 = "snow2";
                                }
                                Vector2 rotate13 = edge.cpy().rotateDeg(0.0f);
                                float offset33 = (((float) Math.abs((((int) Math.abs(rotate13.y / 12.0f)) % 34) - 12)) + ((float) Math.abs((((int) Math.abs(rotate13.y / 12.0f)) % 60) - 30))) / 2.0f;
                                if ((Math.abs((float) ((((int) Math.abs((rotate13.x / 12.0f) - offset33)) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate13.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs((rotate13.x / 12.0f) - offset33)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate13.y / 12.0f)) % 20) - 10))) / 5.0f) > 16.0f) {
                                    name5 = "snow3";
                                }
                                if (!this.noIceHerePlease.contains(edge)) {
                                    Vector2 rotate14 = edge.cpy().add(256.0f, 256.0f).rotate(0.0f);
                                    float offset34 = ((float) Math.sin((double) (rotate14.y / (40.0f * 2.0f)))) * 3.0f;
                                    if ((Math.abs((Math.abs((rotate14.x / 40.0f) - offset34) % 14.0f) - 7.0f) + Math.abs((Math.abs(rotate14.y / 40.0f) % 14.0f) - 7.0f)) * 5.0f * (Math.abs((Math.abs((rotate14.x / 40.0f) - offset34) % 20.0f) - 10.0f) + Math.abs((Math.abs(rotate14.y / 40.0f) % 20.0f) - 10.0f)) > 500.0f) {
                                        name5 = "ice2";
                                    }
                                }
                                if (!name5.equals("ice2")) {
                                    Vector2 rotate15 = edge.cpy().rotateDeg(45.0f);
                                    if ((Math.abs((float) ((((int) Math.abs((rotate15.x / 12.0f) - (rotate15.y / 12.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate15.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate15.x / 12.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate15.y / 12.0f)) % 20) - 10))) / 5.0f) > 14.0f) {
                                        if (this.rand.nextInt(5) < 3) {
                                            name5 = "snow2";
                                            nameUpper7 = "tree4";
                                            if (this.rand.nextInt(3) == 2) {
                                                tempRoute10 = new Route("", 22);
                                                String[] pokemon13 = {"snover"};
                                                tempRoute10.storedPokemon.add(new Pokemon(pokemon13[this.rand.nextInt(pokemon13.length)], 20 + this.rand.nextInt(4)));
                                            }
                                        }
                                        tempRoute10.dontSpawnOverworlds = true;
                                    } else {
                                        Vector2 rotate16 = edge.cpy().rotateDeg(45.0f);
                                        if ((Math.abs((float) ((((int) Math.abs((rotate16.x / 30.0f) - (rotate16.y / 30.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate16.y / 30.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate16.x / 30.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate16.y / 30.0f)) % 20) - 10))) / 5.0f) < 1.0f && this.rand.nextInt(10) < 4) {
                                            nameUpper7 = "berrytree_aspear_full";
                                            if (this.rand.nextInt(6) == 0) {
                                                tempRoute10 = new Route("", 22);
                                                String[] pokemon14 = {"sudowoodo"};
                                                tempRoute10.storedPokemon.add(new Pokemon(pokemon14[this.rand.nextInt(pokemon14.length)], 20 + this.rand.nextInt(4)));
                                            }
                                        }
                                    }
                                } else if (this.rand.nextInt(18) == 0) {
                                    nameUpper7 = "rock_ice2";
                                } else if (this.rand.nextInt(56) == 0) {
                                    name5 = "water6";
                                    nameUpper7 = "ice2_pit1";
                                    if (edge.x % 32.0f == 0.0f && this.rand.nextInt(4) == 0) {
                                        nameUpper7 = "ice2_pit2";
                                        Tile otherTile = new Tile(name5, "solid", edge.cpy().add(16.0f, 0.0f), true, currRoute);
                                        otherTile.biome = "tundra";
                                        tilesToAdd.put(otherTile.position.cpy(), otherTile);
                                        Tile otherTile2 = new Tile(name5, "solid", edge.cpy().add(0.0f, 16.0f), true, currRoute);
                                        otherTile2.biome = "tundra";
                                        tilesToAdd.put(otherTile2.position.cpy(), otherTile2);
                                        Tile otherTile3 = new Tile(name5, "solid", edge.cpy().add(16.0f, 16.0f), true, currRoute);
                                        otherTile3.biome = "tundra";
                                        tilesToAdd.put(otherTile3.position.cpy(), otherTile3);
                                    }
                                }
                                Tile newTile20 = new Tile(name5, nameUpper7, edge, true, tempRoute10);
                                newTile20.biome = "tundra";
                                tilesToAdd.put(newTile20.position.cpy(), newTile20);
                                edgeTiles.put(newTile20.position.cpy(), newTile20);
                            } else if (type.equals("volcano1_lava")) {
                                String name6 = "lava1";
                                Vector2 rotate17 = tile.position.cpy().add(this.randOffset).rotate(45.0f);
                                if ((Math.abs((float) ((((int) Math.abs((rotate17.x / 12.0f) - (rotate17.y / 12.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate17.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate17.x / 12.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate17.y / 12.0f)) % 20) - 10))) / 5.0f) > 22.0f) {
                                    name6 = "volcano2";
                                }
                                Tile newTile21 = new Tile(name6, "", edge, true, currRoute);
                                newTile21.biome = "volcano";
                                game.map.adjustSurroundingTiles(newTile21, tilesToAdd, true);
                                tilesToAdd.put(newTile21.position.cpy(), newTile21);
                                edgeTiles.put(newTile21.position.cpy(), newTile21);
                            } else if (type.equals("volcano1")) {
                                String nameUpper8 = "";
                                Route tempRoute11 = currRoute;
                                Vector2 rotate18 = edge.cpy().add(this.randOffset).rotateDeg(0.0f);
                                float offset35 = (((float) Math.abs((((int) Math.abs(rotate18.y / 12.0f)) % 34) - 12)) + ((float) Math.abs((((int) Math.abs(rotate18.y / 12.0f)) % 60) - 30))) / 2.0f;
                                if ((Math.abs((float) ((((int) Math.abs((rotate18.x / 12.0f) - offset35)) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate18.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs((rotate18.x / 12.0f) - offset35)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate18.y / 12.0f)) % 20) - 10))) / 5.0f) > 16.0f) {
                                    nameUpper8 = "soot1";
                                }
                                Vector2 rotate19 = edge.cpy().add(this.randOffset).rotateDeg(45.0f);
                                if ((Math.abs((float) ((((int) Math.abs((rotate19.x / 12.0f) - (rotate19.y / 12.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate19.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate19.x / 12.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate19.y / 12.0f)) % 20) - 10))) / 5.0f) > 14.0f && this.rand.nextInt(5) == 0) {
                                    nameUpper8 = "rock_volcano1";
                                }
                                if (this.rand.nextInt(50) == 0) {
                                    nameUpper8 = "rock1_color";
                                    if (this.rand.nextInt(2) == 0) {
                                        tempRoute11 = new Route("", 22);
                                        String[] pokemon15 = {"slugma", "geodude"};
                                        tempRoute11.storedPokemon.add(new Pokemon(pokemon15[this.rand.nextInt(pokemon15.length)], tempRoute11.level + this.rand.nextInt(3)));
                                    }
                                }
                                Tile newTile22 = new Tile("volcano1", nameUpper8, edge, true, tempRoute11);
                                newTile22.biome = "volcano";
                                tilesToAdd.put(newTile22.position.cpy(), newTile22);
                                edgeTiles.put(newTile22.position.cpy(), newTile22);
                            } else if (type.equals("wooded_lake1")) {
                                String name7 = "green1";
                                String nameUpper9 = "";
                                Route tempRoute12 = currRoute;
                                if (this.rand.nextInt(8) == 0) {
                                    if (this.rand.nextBoolean()) {
                                        name7 = "flower4";
                                    } else {
                                        name7 = "flower3";
                                        if (edge.x % 32.0f == 0.0f) {
                                            name7 = "flower2";
                                        }
                                    }
                                }
                                Vector2 rotate20 = edge.cpy().rotateDeg(0.0f);
                                float offset36 = (((float) Math.abs((((int) Math.abs(rotate20.y / 12.0f)) % 34) - 12)) + ((float) Math.abs((((int) Math.abs(rotate20.y / 12.0f)) % 60) - 30))) / 2.0f;
                                if ((Math.abs((float) ((((int) Math.abs((rotate20.x / 12.0f) - offset36)) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate20.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs((rotate20.x / 12.0f) - offset36)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate20.y / 12.0f)) % 20) - 10))) / 5.0f) > 16.0f) {
                                    name7 = "grass4";
                                }
                                Vector2 rotate21 = edge.cpy().rotateDeg(45.0f);
                                if ((Math.abs((float) ((((int) Math.abs((rotate21.x / 30.0f) - (rotate21.y / 30.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate21.y / 30.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate21.x / 30.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate21.y / 30.0f)) % 20) - 10))) / 5.0f) > 8.0f) {
                                    if (this.rand.nextInt(5) < 4) {
                                        name7 = "green1";
                                        nameUpper9 = "tree2";
                                        if (this.rand.nextInt(3) == 2) {
                                            tempRoute12 = new Route("", 22);
                                            String[] pokemon16 = {"pineco", "aipom", "kakuna", "metapod", "spinarak", "heracross", "ledyba", "hoothoot", "zubat", "pidgey", "spearow", "forretress", "applin"};
                                            tempRoute12.storedPokemon.add(new Pokemon(pokemon16[this.rand.nextInt(pokemon16.length)], 20 + this.rand.nextInt(4)));
                                        }
                                    }
                                    tempRoute12.dontSpawnOverworlds = true;
                                }
                                Vector2 rotate22 = edge.cpy().rotateDeg(45.0f);
                                if ((Math.abs((float) ((((int) Math.abs((rotate22.x / 16.0f) - (rotate22.y / 16.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate22.y / 16.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate22.x / 16.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate22.y / 16.0f)) % 20) - 10))) / 5.0f) > 36.0f && this.rand.nextInt(10) < 4) {
                                    nameUpper9 = "berrytree_persim_full";
                                    if (this.rand.nextInt(6) == 0) {
                                        tempRoute12 = new Route("", 22);
                                        String[] pokemon17 = {"sudowoodo"};
                                        tempRoute12.storedPokemon.add(new Pokemon(pokemon17[this.rand.nextInt(pokemon17.length)], 20 + this.rand.nextInt(4)));
                                    }
                                }
                                Vector2 rotate23 = edge.cpy().rotateDeg(45.0f);
                                if ((Math.abs((float) ((((int) Math.abs((rotate23.x / 60.0f) - (rotate23.y / 60.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate23.y / 60.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate23.x / 60.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate23.y / 60.0f)) % 20) - 10))) / 5.0f) < 5.0f) {
                                    name7 = "water2";
                                    nameUpper9 = "";
                                    tempRoute12 = beachRoute;
                                }
                                Tile newTile23 = new Tile(name7, nameUpper9, edge, true, tempRoute12);
                                newTile23.biome = "wooded_lake";
                                tilesToAdd.put(newTile23.position.cpy(), newTile23);
                                edgeTiles.put(newTile23.position.cpy(), newTile23);
                            } else if (type.equals("mtn_green1")) {
                                String name8 = "green1";
                                String nameUpper10 = "";
                                Route tempRoute13 = currRoute;
                                if (this.rand.nextInt(8) == 0) {
                                    if (this.rand.nextBoolean()) {
                                        name8 = "flower4";
                                    } else {
                                        name8 = "flower3";
                                        if (edge.x % 32.0f == 0.0f) {
                                            name8 = "flower2";
                                        }
                                    }
                                }
                                Vector2 rotate24 = edge.cpy().rotateDeg(-15.0f);
                                float offsetY5 = (float) ((((int) Math.abs(rotate24.y / 8.0f)) % 14) - 7);
                                float abs = Math.abs(((((float) ((int) Math.abs(rotate24.x / 8.0f))) - (offsetY5 * 2.0f)) % 14.0f) - 7.0f) + Math.abs(offsetY5);
                                float abs2 = ((float) Math.abs((((int) Math.abs(rotate24.x / 8.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate24.y / 8.0f)) % 20) - 10));
                                Vector2 rotate25 = edge.cpy().rotateDeg(0.0f);
                                float offset37 = (((float) Math.abs((((int) Math.abs(rotate25.y / 12.0f)) % 34) - 12)) + ((float) Math.abs((((int) Math.abs(rotate25.y / 12.0f)) % 60) - 30))) / 2.0f;
                                if ((Math.abs((float) ((((int) Math.abs((rotate25.x / 12.0f) - offset37)) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate25.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs((rotate25.x / 12.0f) - offset37)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate25.y / 12.0f)) % 20) - 10))) / 5.0f) > 16.0f) {
                                    name8 = "grass2";
                                }
                                Vector2 rotate26 = edge.cpy().rotateDeg(45.0f);
                                if ((Math.abs((float) ((((int) Math.abs((rotate26.x / 12.0f) - (rotate26.y / 12.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate26.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate26.x / 12.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate26.y / 12.0f)) % 20) - 10))) / 5.0f) > 14.0f && this.rand.nextInt(5) < 3) {
                                    name8 = "green1";
                                    nameUpper10 = "tree2";
                                    if (this.rand.nextInt(3) == 2) {
                                        tempRoute13 = new Route("", 22);
                                        String[] pokemon18 = {"pineco", "aipom", "kakuna", "metapod", "spinarak", "heracross", "ledyba", "hoothoot", "zubat", "pidgey", "spearow", "forretress", "applin"};
                                        tempRoute13.storedPokemon.add(new Pokemon(pokemon18[this.rand.nextInt(pokemon18.length)], 20 + this.rand.nextInt(4)));
                                    }
                                }
                                if (!this.noIceHerePlease.contains(edge)) {
                                    Vector2 rotate27 = edge.cpy().add(256.0f, 256.0f).rotate(0.0f);
                                    float offset38 = ((float) Math.sin((double) (rotate27.y / (40.0f * 2.0f)))) * 3.0f;
                                    if ((Math.abs((Math.abs((rotate27.x / 40.0f) - offset38) % 14.0f) - 7.0f) + Math.abs((Math.abs(rotate27.y / 40.0f) % 14.0f) - 7.0f)) * 5.0f * (Math.abs((Math.abs((rotate27.x / 40.0f) - offset38) % 20.0f) - 10.0f) + Math.abs((Math.abs(rotate27.y / 40.0f) % 20.0f) - 10.0f)) > 500.0f) {
                                        name8 = "water2";
                                        nameUpper10 = "";
                                        tempRoute13 = beachRoute;
                                    }
                                }
                                Tile newTile24 = new Tile(name8, nameUpper10, edge, true, tempRoute13);
                                newTile24.biome = "mountain";
                                tilesToAdd.put(newTile24.position.cpy(), newTile24);
                                edgeTiles.put(newTile24.position.cpy(), newTile24);
                            }
                        }
                    }
                }
                if (tile.position.dst(originTile.position) > prevTile.position.dst(originTile.position) && !tile.name.equals("sand1") && !tile.name.equals("rock1") && !tile.name.equals("tree5")) {
                    prevTile = tile;
                    prevTiles.add(0, tile);
                }
                edgeTiles.remove(tile.position);
            }
        }
        for (Tile tile2 : grassTiles.values()) {
            if (tilesToAdd.containsKey(tile2.position) && !tilesToAdd.get(tile2.position).isSolid) {
                tilesToAdd.put(tile2.position.cpy(), tile2);
            }
        }
        if (isMaze != 0 && forestMazeTiles.size() > 0) {
            Vector2 bl = null;
            Vector2 tr = null;
            for (Tile tile3 : forestMazeTiles.values()) {
                if (bl == null) {
                    bl = tile3.position.cpy();
                }
                if (tr == null) {
                    tr = tile3.position.cpy();
                }
                if (tile3.position.x < bl.x) {
                    bl.x = tile3.position.x;
                } else if (tile3.position.x > tr.x) {
                    tr.x = tile3.position.x;
                }
                if (tile3.position.y < bl.y) {
                    bl.y = tile3.position.y;
                } else if (tile3.position.y > tr.y) {
                    tr.y = tile3.position.y;
                }
            }
            tr.x -= (float) Math.floorMod((int) tr.x, 96);
            bl.x -= (float) Math.floorMod((int) bl.x, 96);
            tr.y += (float) (96 - Math.floorMod((int) tr.y, 96));
            bl.y += (float) (96 - Math.floorMod((int) bl.y, 96));
            for (MazeNode node : GenForest2.Maze_Algo1((((int) (tr.x - bl.x)) * 2) / 96, (((int) (tr.y - bl.y)) * 2) / 96, 0.1f, 0.9f, 96, this.rand).values()) {
                if (node.type == "platform1") {
                    tileSquare = GenForest2.getTileSquarePlatform1(node, bl, this.rand);
                } else {
                    tileSquare = GenForest2.getTileSquare(node, bl, this.rand, true);
                }
                Iterator<Tile> it2 = tileSquare.iterator();
                while (it2.hasNext()) {
                    Tile tile4 = it2.next();
                    if (forestMazeTiles.containsKey(tile4.position)) {
                        tilesToAdd.put(tile4.position.cpy(), tile4);
                    }
                }
            }
            if (tilesToAdd.size() > 0) {
                new GenForest2.ApplyForestBiome(tilesToAdd, bl.cpy(), tr.cpy(), true, null).step(game);
            }
            Iterator it3 = new ArrayList(tilesToAdd.values()).iterator();
            while (it3.hasNext()) {
                Tile tile5 = (Tile) it3.next();
                if ((tile5.name.equals("ledge_grass_down") || tile5.name.equals("ledge_ramp_down")) && tilesToAdd.containsKey(tile5.position.cpy().add(16.0f, 0.0f)) && !tilesToAdd.get(tile5.position.cpy().add(16.0f, 0.0f)).isSolid && !tilesToAdd.get(tile5.position.cpy().add(16.0f, 0.0f)).isLedge) {
                    HashMap<Vector2, Tile> upTiles = new HashMap<>();
                    HashMap<Vector2, Tile> rightTiles = new HashMap<>();
                    upTiles.put(tile5.position.cpy().add(16.0f, 0.0f), new Tile("ledge1_corner_br", tile5.position.cpy().add(16.0f, 0.0f), true));
                    rightTiles.put(tile5.position.cpy().add(16.0f, 0.0f), new Tile("ledge_grass_down", tile5.position.cpy().add(16.0f, 0.0f), true));
                    for (int i2 = 16; i2 < 80; i2 += 16) {
                        if (tilesToAdd.containsKey(tile5.position.cpy().add(16.0f, (float) i2)) && (tilesToAdd.get(tile5.position.cpy().add(16.0f, (float) i2)).isSolid || tilesToAdd.get(tile5.position.cpy().add(16.0f, (float) i2)).isLedge)) {
                            tilesToAdd.putAll(upTiles);
                            break;
                        }
                        if (tilesToAdd.containsKey(tile5.position.cpy().add((float) (16 + i2), 0.0f)) && (tilesToAdd.get(tile5.position.cpy().add((float) (16 + i2), 0.0f)).isSolid || tilesToAdd.get(tile5.position.cpy().add((float) (16 + i2), 0.0f)).isLedge)) {
                            tilesToAdd.putAll(rightTiles);
                            break;
                        }
                        upTiles.put(tile5.position.cpy().add(16.0f, (float) i2), new Tile("ledge1_right", tile5.position.cpy().add(16.0f, (float) i2), true));
                        rightTiles.put(tile5.position.cpy().add((float) (16 + i2), 0.0f), new Tile("ledge_grass_down", tile5.position.cpy().add((float) (16 + i2), 0.0f), true));
                    }
                }
                if ((tile5.name.equals("ledge_grass_down") || tile5.name.equals("ledge_ramp_down")) && tilesToAdd.containsKey(tile5.position.cpy().add(-16.0f, 0.0f)) && !tilesToAdd.get(tile5.position.cpy().add(-16.0f, 0.0f)).isSolid && !tilesToAdd.get(tile5.position.cpy().add(-16.0f, 0.0f)).isLedge) {
                    HashMap<Vector2, Tile> upTiles2 = new HashMap<>();
                    HashMap<Vector2, Tile> leftTiles = new HashMap<>();
                    upTiles2.put(tile5.position.cpy().add(-16.0f, 0.0f), new Tile("ledge1_corner_bl", tile5.position.cpy().add(-16.0f, 0.0f), true));
                    leftTiles.put(tile5.position.cpy().add(-16.0f, 0.0f), new Tile("ledge_grass_down", tile5.position.cpy().add(-16.0f, 0.0f), true));
                    for (int i3 = 16; i3 < 80; i3 += 16) {
                        if (tilesToAdd.containsKey(tile5.position.cpy().add(-16.0f, (float) i3)) && (tilesToAdd.get(tile5.position.cpy().add(-16.0f, (float) i3)).isSolid || tilesToAdd.get(tile5.position.cpy().add(-16.0f, (float) i3)).isLedge)) {
                            tilesToAdd.putAll(upTiles2);
                            break;
                        }
                        if (tilesToAdd.containsKey(tile5.position.cpy().add((float) (-16 - i3), 0.0f)) && (tilesToAdd.get(tile5.position.cpy().add((float) (-16 - i3), 0.0f)).isSolid || tilesToAdd.get(tile5.position.cpy().add((float) (-16 - i3), 0.0f)).isLedge)) {
                            tilesToAdd.putAll(leftTiles);
                            break;
                        }
                        upTiles2.put(tile5.position.cpy().add(-16.0f, (float) i3), new Tile("ledge1_left", tile5.position.cpy().add(-16.0f, (float) i3), true));
                        leftTiles.put(tile5.position.cpy().add((float) (-16 - i3), 0.0f), new Tile("ledge_grass_down", tile5.position.cpy().add((float) (-16 - i3), 0.0f), true));
                    }
                }
                if (deepForestMazeTiles.contains(tile5.position)) {
                    tile5.routeBelongsTo = deepForestRoute;
                    tile5.biome = "deep_forest";
                    if (tile5.name.equals("grass2")) {
                        tile5.name = "grass4";
                    }
                    tile5.init();
                }
            }
        }
        if (type.equals("graveyard1")) {
            for (int numFences = this.rand.nextInt(4) + 1; numFences > 0 && !fenceSpawns.isEmpty(); numFences--) {
                boolean doneDoll = false;
                Vector2 edge2 = fenceSpawns.remove(this.rand.nextInt(fenceSpawns.size()));
                int size = 4 + this.rand.nextInt(3);
                int left = this.rand.nextInt(size);
                int doorOffset = this.rand.nextInt(2) * 16;
                int numDoors = this.rand.nextInt(4) + 1;
                Vector2 bl2 = edge2.cpy().add((float) (-16 * left), (float) (-16 * left));
                bl2.x += bl2.x % 32.0f;
                bl2.y += (((bl2.y / 16.0f) % 2.0f) + ((float) ((int) (((bl2.y / 32.0f) % 11.0f) / 5.0f)))) * 16.0f;
                Vector2 tr2 = bl2.cpy().add((float) (16 * size), (float) (16 * size));
                tr2.x += tr2.x % 32.0f;
                tr2.y += (((tr2.y / 16.0f) % 2.0f) + ((float) ((int) (((tr2.y / 32.0f) % 11.0f) / 5.0f)))) * 16.0f;
                Vector2 currPos = bl2.cpy();
                while (currPos.y <= tr2.y) {
                    String name9 = "flower5";
                    String nameUpper11 = "";
                    boolean replace = true;
                    if (currPos.x == bl2.x && currPos.y == bl2.y) {
                        name9 = "green12";
                        nameUpper11 = "fence1_NE";
                    } else if (currPos.x == tr2.x && currPos.y == tr2.y) {
                        name9 = "green12";
                        nameUpper11 = "fence1_SW";
                    } else if (currPos.x == bl2.x && currPos.y == tr2.y) {
                        name9 = "green12";
                        nameUpper11 = "fence1_SE";
                    } else if (currPos.x == tr2.x && currPos.y == bl2.y) {
                        name9 = "green12";
                        nameUpper11 = "fence1_NW";
                    } else if (currPos.y == bl2.y || currPos.y == tr2.y) {
                        name9 = "green12";
                        nameUpper11 = "fence1";
                        if (numDoors > 0 && currPos.x == bl2.x + ((float) ((size / 2) * 16)) + ((float) doorOffset)) {
                            nameUpper11 = "house5_door1";
                            numDoors--;
                        }
                    } else if (currPos.x == bl2.x || currPos.x == tr2.x) {
                        name9 = "green12";
                        nameUpper11 = "fence1_NS";
                        if (this.rand.nextBoolean() && numDoors > 0 && currPos.y == bl2.y + ((float) ((size / 2) * 16)) + ((float) doorOffset)) {
                            nameUpper11 = "house5_door1";
                            numDoors--;
                        }
                    } else {
                        if (tilesToAdd.get(currPos) != null) {
                            if (!tilesToAdd.get(currPos).nameUpper.equals("") && currPos.y != bl2.y + 16.0f) {
                                replace = false;
                            }
                            if (tilesToAdd.get(currPos).nameUpper.contains("fence")) {
                                replace = true;
                            }
                        }
                        if (!(!replace || currPos.y % 32.0f != 0.0f || currPos.x == bl2.x + 16.0f || currPos.x == tr2.x - 16.0f || currPos.y == bl2.y + 16.0f)) {
                            this.keystoneSpawns.add(currPos.cpy());
                            if (this.rand.nextInt(3) == 0) {
                                name9 = "green12";
                                nameUpper11 = "gravestone2";
                            }
                            if (!doneDoll && (size <= 5 || this.rand.nextInt(3) == 0)) {
                                doneDoll = true;
                                int randInt3 = this.rand.nextInt(3);
                                nameUpper11 = "pokedoll1";
                                if (randInt3 == 0) {
                                    nameUpper11 = "pokedoll1_mimikyu";
                                } else if (randInt3 == 1) {
                                    nameUpper11 = "pokedoll1_banette";
                                }
                            }
                        }
                    }
                    if (replace) {
                        Tile newTile25 = new Tile(name9, nameUpper11, currPos.cpy(), true, currRoute);
                        newTile25.biome = "graveyard";
                        tilesToAdd.put(currPos.cpy(), newTile25);
                        game.map.adjustSurroundingTiles(newTile25, tilesToAdd, true);
                    }
                    currPos.x += 16.0f;
                    if (currPos.x > tr2.x) {
                        currPos.x = bl2.x;
                        currPos.y += 16.0f;
                    }
                }
            }
        }
        if (newSize > 0) {
            int[] vals = {1, 1, 2, 3};
            int randInt4 = vals[this.rand.nextInt(vals.length)];
            if (prevTiles.size() < randInt4) {
                randInt4 = prevTiles.size();
            }
            HashMap<Vector2, Tile> nextIslandTiles = new HashMap<>();
            int next = 0;
            if (type.equals("oasis1")) {
                int[] vals2 = {3, 3, 4, 4, 5, 5};
                randInt4 = vals2[this.rand.nextInt(vals2.length)];
                if (prevTiles.size() < randInt4) {
                    randInt4 = prevTiles.size();
                }
                newSize += maxDist / 10;
            } else if (type.equals("sand_pit1")) {
                if (randInt4 > 1) {
                    randInt4 = 1;
                }
                if (numSandPits >= 20) {
                    newSize = 1;
                } else {
                    numSandPits++;
                }
            } else if (type.equals("beach1")) {
                newSize = maxDist;
                int isMaze2 = isMaze - 1;
                if (prevTiles.size() > 0 && isMaze2 > 0) {
                    Tile origin = prevTiles.get(0);
                    tilesToAdd.put(origin.position.cpy(), origin);
                    ApplyBlotch(game, type, origin, newSize, nextIslandTiles, isMaze2, true, currRoute);
                }
            }
            if ((type.equals("island") || type.equals("desert") || type.equals("oasis1") || type.equals("sand_pit1") || type.equals("wooded_lake1")) && doNext) {
                for (int i4 = 0; i4 < randInt4; i4++) {
                    if (this.doneDesert != 1) {
                        tilesToAdd.put(prevTiles.get(next).position.cpy(), prevTiles.get(next));
                        String newType = type;
                        if (type.equals("desert")) {
                            newType = "island";
                            currRoute = new Route("forest1", 40);
                        } else if (!type.equals("wooded_lake1") && this.doneDesert > 1 && !newType.equals("sand_pit1") && !newType.equals("oasis1") && this.rand.nextInt(5) == 0) {
                            currRoute = new Route("wooded_lake1", 40);
                            newType = "wooded_lake1";
                            if (newSize < 400) {
                                newSize = 400;
                            }
                        }
                        ApplyBlotch(game, newType, prevTiles.get(next), newSize, nextIslandTiles, 1, true, currRoute);
                        next += this.rand.nextInt(prevTiles.size() - next) + next;
                        if (next >= prevTiles.size()) {
                            break;
                        }
                    } else {
                        tilesToAdd.put(prevTiles.get(next).position.cpy(), prevTiles.get(next));
                        ApplyBlotch(game, "desert", prevTiles.get(next), newSize + (maxDist / 4), nextIslandTiles, 1, true, new Route("desert1", 40));
                    }
                }
            }
            if (prevTiles.size() > 1 && (type.equals("island") || type.equals("wooded_lake1"))) {
                ApplyBlotch(game, "beach1", prevTiles.remove(1), 400, nextIslandTiles, 6, false, new Route("beach2", 12));
            }
            for (Tile tile6 : nextIslandTiles.values()) {
                if (tilesToAdd.containsKey(tile6.position)) {
                    Tile currTile = tilesToAdd.get(tile6.position);
                    if (type.equals("beach1")) {
                        if (tile6.name.contains("sand4") || tile6.name.equals("mountain4")) {
                            tilesToAdd.put(tile6.position.cpy(), tile6);
                        }
                    } else if (type.equals("sand_pit1")) {
                        if (tile6.name.equals("desert2")) {
                            tilesToAdd.put(tile6.position.cpy(), tile6);
                        }
                    } else if (tile6.name.contains("desert")) {
                        tilesToAdd.put(tile6.position.cpy(), tile6);
                    } else if (!currTile.name.contains("desert")) {
                        if (tile6.routeBelongsTo != null && tile6.routeBelongsTo.name.equals("wooded_lake1")) {
                            tilesToAdd.put(tile6.position.cpy(), tile6);
                        } else if (!type.equals("wooded_lake1") && type.equals("island")) {
                            if ((currTile.name.equals("sand1") || currTile.name.equals("rock1") || currTile.name.equals("tree5") || currTile.name.equals("grass_sand1")) && !tile6.name.equals("sand1")) {
                                tilesToAdd.put(tile6.position.cpy(), tile6);
                            }
                            if (tile6.name.equals("tree_large1") && !forestMazeTiles.containsKey(tile6.position)) {
                                tilesToAdd.put(tile6.position.cpy(), tile6);
                                tilesToAdd.put(tile6.position.cpy().add(16.0f, 0.0f), new Tile("tree_large1_noSprite", tile6.position.cpy().add(16.0f, 0.0f)));
                                tilesToAdd.put(tile6.position.cpy().add(0.0f, 16.0f), new Tile("tree_large1_noSprite", tile6.position.cpy().add(0.0f, 16.0f)));
                                tilesToAdd.put(tile6.position.cpy().add(16.0f, 16.0f), new Tile("tree_large1_noSprite", tile6.position.cpy().add(16.0f, 16.0f)));
                            }
                            if (tile6.nameUpper.equals("tree2") && !forestMazeTiles.containsKey(tile6.position)) {
                                tilesToAdd.put(tile6.position.cpy(), tile6);
                            }
                        }
                    }
                } else {
                    tilesToAdd.put(tile6.position.cpy(), tile6);
                }
            }
        }
    }

    public ArrayList<Tile> ApplyBlotchMountain(Game game, Tile originTile, int maxDist, HashMap<Vector2, Tile> tilesToAdd) {
        ArrayList<Tile> edgeTiles = new ArrayList<>();
        HashMap<Tile, Vector2> edgeDirs = new HashMap<>();
        HashMap<Vector2, Tile> mtnTiles = new HashMap<>();
        Tile copyTile = new Tile(originTile.name, originTile.position.cpy());
        edgeTiles.add(originTile);
        edgeTiles.add(copyTile);
        Vector2 dir1 = new Vector2((float) (this.rand.nextInt(200) - 100), (float) (this.rand.nextInt(200) - 100));
        Vector2 dir2 = dir1.cpy().rotate(180.0f);
        edgeDirs.put(originTile, dir1);
        edgeDirs.put(copyTile, dir2);
        HashMap<Tile, Vector2> origins = new HashMap<>();
        HashMap<Tile, Integer> originDists = new HashMap<>();
        origins.put(originTile, originTile.position.cpy());
        origins.put(copyTile, originTile.position.cpy());
        originDists.put(originTile, Integer.valueOf(maxDist));
        originDists.put(copyTile, Integer.valueOf(maxDist));
        Tile copyTile2 = new Tile(originTile.name, originTile.position.cpy());
        Tile copyTile3 = new Tile(originTile.name, originTile.position.cpy());
        edgeTiles.add(copyTile2);
        edgeTiles.add(copyTile3);
        edgeDirs.put(copyTile2, dir1.cpy().rotateDeg(90.0f));
        edgeDirs.put(copyTile3, dir2.cpy().rotateDeg(90.0f));
        origins.put(copyTile2, originTile.position.cpy());
        origins.put(copyTile3, originTile.position.cpy());
        originDists.put(copyTile2, Integer.valueOf((int) ((2.0f * ((float) Math.abs(maxDist))) / 8.0f)));
        originDists.put(copyTile3, Integer.valueOf((int) ((2.0f * ((float) Math.abs(maxDist))) / 8.0f)));
        ArrayList<Tile> endPoints = new ArrayList<>();
        this.noIceHerePlease.clear();
        int currLevel = 0;
        int newLevel = 0;
        int numLayers = 0;
        int[] levels2 = {0, 0, -1, -1, -1};
        HashMap<Vector2, Tile> levelTiles = new HashMap<>();
        HashMap<Tile, Integer> tileLevels = new HashMap<>();
        levelTiles.put(originTile.position.cpy(), originTile);
        levelTiles.put(copyTile.position.cpy(), copyTile);
        tileLevels.put(originTile, 0);
        tileLevels.put(copyTile, 0);
        Route mtnRoute = new Route("mountain1", 33);
        Route snowRoute = new Route("snow1", 44);
        while (true) {
            if (!edgeTiles.isEmpty() || ((double) currLevel) > (-Math.ceil((double) (maxDist / WinError.ERROR_ENCRYPTION_FAILED))) || numLayers < 13) {
                System.out.println(newLevel);
                Iterator it = new ArrayList(edgeTiles).iterator();
                while (it.hasNext()) {
                    Tile tile = (Tile) it.next();
                    edgeTiles.remove(tile);
                    Vector2 currDir = edgeDirs.get(tile);
                    edgeDirs.remove(tile);
                    float distance = tile.position.dst(origins.get(tile));
                    int maxDist2 = originDists.get(tile).intValue();
                    if ((this.rand.nextInt(maxDist2 + 1) + ((int) distance)) - (maxDist2 / 32) < maxDist2) {
                        Vector2 newDir = new Vector2();
                        if (((float) (this.rand.nextInt(Math.abs((int) currDir.x) + 1) + this.rand.nextInt(Math.abs((int) currDir.y) + 1))) < Math.abs(currDir.y) + 2.0f) {
                            if (currDir.y < 0.0f) {
                                newDir.x = 0.0f;
                                newDir.y = -1.0f;
                            } else {
                                newDir.x = 0.0f;
                                newDir.y = 1.0f;
                            }
                        } else if (currDir.x < 0.0f) {
                            newDir.x = -1.0f;
                            newDir.y = 0.0f;
                        } else {
                            newDir.x = 1.0f;
                            newDir.y = 0.0f;
                        }
                        Tile nextTile = new Tile("mountain1", "", tile.position.cpy().add(16.0f * newDir.x, 16.0f * newDir.y), true, mtnRoute);
                        mtnTiles.put(nextTile.position.cpy(), nextTile);
                        edgeTiles.add(nextTile);
                        edgeDirs.put(nextTile, currDir);
                        origins.put(nextTile, origins.get(tile));
                        originDists.put(nextTile, originDists.get(tile));
                        levelTiles.put(nextTile.position.cpy(), nextTile);
                        tileLevels.put(nextTile, Integer.valueOf(newLevel));
                        if (this.rand.nextInt((int) Math.ceil((double) (1.0f / (4.0f / (((float) (maxDist + maxDist2)) / 350.0f))))) == 1) {
                            int degrees = this.rand.nextInt(80) + 10;
                            Vector2 branchDir = currDir.cpy().rotate((float) degrees);
                            Tile nextTile2 = new Tile("mountain1", "", tile.position.cpy(), true, mtnRoute);
                            edgeTiles.add(nextTile2);
                            edgeDirs.put(nextTile2, branchDir);
                            origins.put(nextTile2, tile.position.cpy());
                            originDists.put(nextTile2, Integer.valueOf((int) ((1.0f * Math.abs(((float) maxDist2) - distance)) / 8.0f)));
                            Vector2 branchDir2 = currDir.cpy().rotate((float) (-degrees));
                            Tile nextTile3 = new Tile("mountain1", "", tile.position.cpy(), true, mtnRoute);
                            edgeTiles.add(nextTile3);
                            edgeDirs.put(nextTile3, branchDir2);
                            origins.put(nextTile3, tile.position.cpy());
                            originDists.put(nextTile3, Integer.valueOf((int) ((1.0f * Math.abs(((float) maxDist2) - distance)) / 8.0f)));
                        }
                    } else if (distance > 100.0f) {
                        System.out.println("distance");
                        System.out.println(distance);
                        endPoints.add(tile);
                    }
                    origins.remove(tile);
                    originDists.remove(tile);
                }
                if (this.rand.nextInt((int) Math.ceil((double) (1.0f / (1.0f / (((float) maxDist) / 1000.0f))))) == 1) {
                    if (numLayers < 10) {
                        newLevel = currLevel + levels2[this.rand.nextInt(levels2.length)];
                    } else if (numLayers >= maxDist / WinError.ERROR_INVALID_PRIORITY) {
                        newLevel--;
                    }
                    AddMtnLayer(levelTiles, tileLevels, mtnTiles, newLevel, newLevel <= -1 ? "mountain3" : "snow1", newLevel <= -1 ? mtnRoute : snowRoute, numLayers >= 10 && numLayers < maxDist / WinError.ERROR_INVALID_PRIORITY);
                    currLevel = newLevel;
                    numLayers++;
                }
            }
        }
        while (numLayers <= maxDist / WinError.ERROR_INVALID_PRIORITY) {
            AddMtnLayer(levelTiles, tileLevels, mtnTiles, currLevel, currLevel <= -1 ? "mountain3" : "snow1", currLevel <= -1 ? mtnRoute : snowRoute, numLayers >= 10 && numLayers <= maxDist / WinError.ERROR_INVALID_PRIORITY);
            numLayers++;
        }
        AddMtnLayer(levelTiles, tileLevels, mtnTiles, currLevel - 1, "mountain3", mtnRoute, false);
        AddMtnLayer(levelTiles, tileLevels, mtnTiles, currLevel - 2, "mountain3", mtnRoute, false);
        int bottomLevel = currLevel - 2;
        Route volcanoRoute = new Route("volcano1", 22);
        levelTiles.clear();
        HashMap<Vector2, Tile> volcanoTiles = new HashMap<>();
        ApplyBlotch(game, "volcano1", originTile, WinError.ERROR_FAIL_NOACTION_REBOOT, volcanoTiles, 0, false, volcanoRoute);
        levelTiles.clear();
        ApplyBlotch(game, "volcano1_lava", originTile, 200, levelTiles, 0, false, volcanoRoute);
        ledgify(levelTiles, levelTiles, "volcano2", "lava1_", "volcano");
        volcanoTiles.putAll(levelTiles);
        ledgify(volcanoTiles, volcanoTiles, "volcano1", "lava1_", "volcano", "volcano1");
        for (Tile tile2 : volcanoTiles.values()) {
            if (tile2.nameUpper.equals("soot1")) {
                tile2.name = tile2.nameUpper;
                tile2.nameUpper = "";
                tile2.init();
            }
        }
        levelTiles.clear();
        levelTiles.putAll(volcanoTiles);
        for (Tile tile3 : levelTiles.values()) {
            tileLevels.put(tile3, -5);
        }
        int currLevel2 = -5 + 1;
        AddMtnLayer(levelTiles, tileLevels, volcanoTiles, -5, "volcano1", volcanoRoute, false);
        int currLevel3 = currLevel2 + 1;
        AddMtnLayer(levelTiles, tileLevels, volcanoTiles, currLevel2, "volcano1", volcanoRoute, false);
        int currLevel4 = currLevel3 + 1;
        AddMtnLayer(levelTiles, tileLevels, volcanoTiles, currLevel3, "volcano1", volcanoRoute, false);
        int currLevel5 = currLevel4 + 1;
        AddMtnLayer(levelTiles, tileLevels, volcanoTiles, currLevel4, "volcano1", volcanoRoute, false);
        int currLevel6 = currLevel5 + 1;
        AddMtnLayer(levelTiles, tileLevels, volcanoTiles, currLevel5, "volcano1", volcanoRoute, false);
        AddMtnLayer(levelTiles, tileLevels, volcanoTiles, currLevel6, "mountain3", volcanoRoute, false);
        AddMtnLayer(levelTiles, tileLevels, volcanoTiles, currLevel6, "mountain3", volcanoRoute, false);
        mtnTiles.putAll(volcanoTiles);
        HashMap<Vector2, Tile> biomeTiles = new HashMap<>();
        boolean done = false;
        while (!done) {
            done = true;
            for (Tile tile4 : mtnTiles.values()) {
                Tile bl = mtnTiles.get(tile4.position.cpy().add(-16.0f, -16.0f));
                Tile bot = mtnTiles.get(tile4.position.cpy().add(0.0f, -16.0f));
                Tile br = mtnTiles.get(tile4.position.cpy().add(16.0f, -16.0f));
                Tile left = mtnTiles.get(tile4.position.cpy().add(-16.0f, 0.0f));
                Tile tl = mtnTiles.get(tile4.position.cpy().add(-16.0f, 16.0f));
                Tile top = mtnTiles.get(tile4.position.cpy().add(0.0f, 16.0f));
                Tile tr = mtnTiles.get(tile4.position.cpy().add(16.0f, 16.0f));
                Tile right = mtnTiles.get(tile4.position.cpy().add(16.0f, 0.0f));
                if ((!tileLevels.containsKey(left) || tileLevels.get(left).intValue() >= tileLevels.get(tile4).intValue() - 1) && ((!tileLevels.containsKey(right) || tileLevels.get(right).intValue() >= tileLevels.get(tile4).intValue() - 1) && ((!tileLevels.containsKey(bot) || tileLevels.get(bot).intValue() >= tileLevels.get(tile4).intValue() - 1) && ((!tileLevels.containsKey(top) || tileLevels.get(top).intValue() >= tileLevels.get(tile4).intValue() - 1) && ((!tileLevels.containsKey(tr) || tileLevels.get(tr).intValue() >= tileLevels.get(tile4).intValue() - 1) && ((!tileLevels.containsKey(tl) || tileLevels.get(tl).intValue() >= tileLevels.get(tile4).intValue() - 1) && ((!tileLevels.containsKey(bl) || tileLevels.get(bl).intValue() >= tileLevels.get(tile4).intValue() - 1) && (!tileLevels.containsKey(br) || tileLevels.get(br).intValue() >= tileLevels.get(tile4).intValue() - 1)))))))) {
                    if (tileLevels.containsKey(left) && tileLevels.get(left).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(right) && tileLevels.get(right).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(top) && tileLevels.get(top).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(bot) && tileLevels.get(bot).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(top) && tileLevels.get(top).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(left) && tileLevels.get(left).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(br) && tileLevels.get(br).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(top) && tileLevels.get(top).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(right) && tileLevels.get(right).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(bl) && tileLevels.get(bl).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(bot) && tileLevels.get(bot).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(right) && tileLevels.get(right).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(tl) && tileLevels.get(tl).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(bot) && tileLevels.get(bot).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(left) && tileLevels.get(left).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(tr) && tileLevels.get(tr).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(bot) && tileLevels.get(bot) == tileLevels.get(tile4) && tileLevels.containsKey(left) && tileLevels.get(left).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(br) && tileLevels.get(br).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(bot) && tileLevels.get(bot) == tileLevels.get(tile4) && tileLevels.containsKey(right) && tileLevels.get(right).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(bl) && tileLevels.get(bl).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(top) && tileLevels.get(top) == tileLevels.get(tile4) && tileLevels.containsKey(left) && tileLevels.get(left).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(tr) && tileLevels.get(tr).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(top) && tileLevels.get(top) == tileLevels.get(tile4) && tileLevels.containsKey(right) && tileLevels.get(right).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(tl) && tileLevels.get(tl).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(right) && tileLevels.get(right) == tileLevels.get(tile4) && tileLevels.containsKey(top) && tileLevels.get(top).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(br) && tileLevels.get(br).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(right) && tileLevels.get(right) == tileLevels.get(tile4) && tileLevels.containsKey(bot) && tileLevels.get(bot).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(tr) && tileLevels.get(tr).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(left) && tileLevels.get(left) == tileLevels.get(tile4) && tileLevels.containsKey(bot) && tileLevels.get(bot).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(tl) && tileLevels.get(tl).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                    if (tileLevels.containsKey(left) && tileLevels.get(left) == tileLevels.get(tile4) && tileLevels.containsKey(top) && tileLevels.get(top).intValue() <= tileLevels.get(tile4).intValue() - 1 && tileLevels.containsKey(bl) && tileLevels.get(bl).intValue() <= tileLevels.get(tile4).intValue() - 1) {
                        tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                        done = false;
                    }
                } else {
                    tileLevels.put(tile4, Integer.valueOf(tileLevels.get(tile4).intValue() - 1));
                    done = false;
                }
            }
        }
        for (Tile tile5 : mtnTiles.values()) {
            Tile bl2 = mtnTiles.get(tile5.position.cpy().add(-16.0f, -16.0f));
            Tile bot2 = mtnTiles.get(tile5.position.cpy().add(0.0f, -16.0f));
            Tile br2 = mtnTiles.get(tile5.position.cpy().add(16.0f, -16.0f));
            Tile left2 = mtnTiles.get(tile5.position.cpy().add(-16.0f, 0.0f));
            Tile tl2 = mtnTiles.get(tile5.position.cpy().add(-16.0f, 16.0f));
            Tile top2 = mtnTiles.get(tile5.position.cpy().add(0.0f, 16.0f));
            Tile tr2 = mtnTiles.get(tile5.position.cpy().add(16.0f, 16.0f));
            Tile right2 = mtnTiles.get(tile5.position.cpy().add(16.0f, 0.0f));
            if (tileLevels.containsKey(left2) && tileLevels.get(left2) == tileLevels.get(tile5) && tileLevels.containsKey(bot2) && tileLevels.get(bot2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(right2) && tileLevels.get(right2) == tileLevels.get(tile5)) {
                tile5.nameUpper = "ledges3_N";
                tile5.init();
            } else if (tileLevels.containsKey(top2) && tileLevels.get(top2) == tileLevels.get(tile5) && tileLevels.containsKey(right2) && tileLevels.get(right2) == tileLevels.get(tile5) && tileLevels.containsKey(bot2) && tileLevels.get(bot2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(left2) && tileLevels.get(left2).intValue() == tileLevels.get(tile5).intValue() - 1) {
                tile5.nameUpper = "ledges3_NE";
                tile5.init();
            } else if (tileLevels.containsKey(top2) && tileLevels.get(top2) == tileLevels.get(tile5) && tileLevels.containsKey(left2) && tileLevels.get(left2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(bot2) && tileLevels.get(bot2) == tileLevels.get(tile5)) {
                tile5.nameUpper = "ledges3_E";
                tile5.init();
            } else if (tileLevels.containsKey(top2) && tileLevels.get(top2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(left2) && tileLevels.get(left2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(right2) && tileLevels.get(right2) == tileLevels.get(tile5) && tileLevels.containsKey(bot2) && tileLevels.get(bot2) == tileLevels.get(tile5)) {
                tile5.nameUpper = "ledges3_SE";
                tile5.init();
            } else if (tileLevels.containsKey(top2) && tileLevels.get(top2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(left2) && tileLevels.get(left2) == tileLevels.get(tile5) && tileLevels.containsKey(right2) && tileLevels.get(right2) == tileLevels.get(tile5)) {
                tile5.nameUpper = "ledges3_S";
                tile5.init();
            } else if (tileLevels.containsKey(top2) && tileLevels.get(top2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(bot2) && tileLevels.get(bot2) == tileLevels.get(tile5) && tileLevels.containsKey(left2) && tileLevels.get(left2) == tileLevels.get(tile5) && tileLevels.containsKey(right2) && tileLevels.get(right2).intValue() == tileLevels.get(tile5).intValue() - 1) {
                tile5.nameUpper = "ledges3_SW";
                tile5.init();
            } else if (tileLevels.containsKey(top2) && tileLevels.get(top2) == tileLevels.get(tile5) && tileLevels.containsKey(bot2) && tileLevels.get(bot2) == tileLevels.get(tile5) && tileLevels.containsKey(right2) && tileLevels.get(right2).intValue() == tileLevels.get(tile5).intValue() - 1) {
                tile5.nameUpper = "ledges3_W";
                tile5.init();
            } else if (tileLevels.containsKey(top2) && tileLevels.get(top2) == tileLevels.get(tile5) && tileLevels.containsKey(left2) && tileLevels.get(left2) == tileLevels.get(tile5) && tileLevels.containsKey(bot2) && tileLevels.get(bot2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(right2) && tileLevels.get(right2).intValue() == tileLevels.get(tile5).intValue() - 1) {
                tile5.nameUpper = "ledges3_NW";
                tile5.init();
            } else if (tileLevels.containsKey(br2) && tileLevels.get(br2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(bot2) && tileLevels.get(bot2) == tileLevels.get(tile5) && tileLevels.containsKey(right2) && tileLevels.get(right2) == tileLevels.get(tile5)) {
                tile5.nameUpper = "ledges3_NW_inner";
                tile5.init();
            } else if (tileLevels.containsKey(bl2) && tileLevels.get(bl2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(bot2) && tileLevels.get(bot2) == tileLevels.get(tile5) && tileLevels.containsKey(left2) && tileLevels.get(left2) == tileLevels.get(tile5)) {
                tile5.nameUpper = "ledges3_NE_inner";
                tile5.init();
            } else if (tileLevels.containsKey(tr2) && tileLevels.get(tr2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(top2) && tileLevels.get(top2) == tileLevels.get(tile5) && tileLevels.containsKey(right2) && tileLevels.get(right2) == tileLevels.get(tile5)) {
                tile5.nameUpper = "ledges3_SW_inner";
                tile5.init();
            } else if (tileLevels.containsKey(tl2) && tileLevels.get(tl2).intValue() == tileLevels.get(tile5).intValue() - 1 && tileLevels.containsKey(top2) && tileLevels.get(top2) == tileLevels.get(tile5) && tileLevels.containsKey(left2) && tileLevels.get(left2) == tileLevels.get(tile5)) {
                tile5.nameUpper = "ledges3_SE_inner";
                tile5.init();
            }
        }
        Iterator it2 = new ArrayList(mtnTiles.values()).iterator();
        while (it2.hasNext()) {
            Tile tile6 = (Tile) it2.next();
            if (this.rand.nextInt((int) Math.ceil((double) (1.0f / (1.0f / (((float) maxDist) / 500.0f))))) == 1) {
                float distance2 = tile6.position.dst(originTile.position);
                int level = (int) (30.0f * (1.0f - (tile6.position.dst(this.origin) / ((float) (this.radius / 12)))));
                if (level < 4) {
                    level = 4;
                }
                if (tileLevels.get(tile6).intValue() <= currLevel6) {
                    level = 10;
                } else if (level > 30) {
                    level = 30;
                }
                if (distance2 < ((float) ((1 * maxDist) / 40))) {
                    ApplyBlotch(game, "mtn_snow1", tile6, 7 * ((int) (((float) maxDist) / distance2)), biomeTiles, 0, false, new Route("snow1", level));
                } else {
                    ApplyBlotch(game, "mtn_green1", tile6, maxDist / 240, biomeTiles, 0, false, new Route("mountain1", level));
                }
            }
        }
        Iterator it3 = new ArrayList(mtnTiles.values()).iterator();
        while (it3.hasNext()) {
            Tile tile7 = (Tile) it3.next();
            if (!this.noIceHerePlease.contains(tile7.position)) {
                Vector2 rotate = tile7.position.cpy().rotate(45.0f);
                if ((Math.abs((float) ((((int) Math.abs((rotate.x / 12.0f) - (rotate.y / 12.0f))) % 14) - 7)) + Math.abs((float) ((((int) Math.abs(rotate.y / 12.0f)) % 14) - 7))) * ((((float) Math.abs((((int) Math.abs(rotate.x / 12.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate.y / 12.0f)) % 20) - 10))) / 5.0f) > 14.0f) {
                    tile7.name = "mountain4";
                    tile7.init();
                }
            }
            if (this.rand.nextInt(24) == 0 && !biomeTiles.containsKey(tile7.position)) {
                Route tempRoute = null;
                if (this.rand.nextInt(2) == 0) {
                    tempRoute = new Route("", 22);
                    String[] pokemon = {"slugma", "geodude", "shuckle"};
                    tempRoute.storedPokemon.add(new Pokemon(pokemon[this.rand.nextInt(pokemon.length)], tempRoute.level + this.rand.nextInt(3)));
                }
                biomeTiles.put(tile7.position.cpy(), new Tile(tile7.name, "rock1_color", tile7.position.cpy(), true, tempRoute));
            }
            if (tile7.name.equals("mountain3")) {
                Vector2 rotate2 = tile7.position.cpy().rotateDeg(-15.0f);
                float offsetY = (float) ((((int) Math.abs(rotate2.y / 8.0f)) % 14) - 7);
                if ((Math.abs(((((float) ((int) Math.abs(rotate2.x / 8.0f))) - (offsetY * 2.0f)) % 14.0f) - 7.0f) + Math.abs(offsetY)) * ((((float) Math.abs((((int) Math.abs(rotate2.x / 8.0f)) % 20) - 10)) + ((float) Math.abs((((int) Math.abs(rotate2.y / 8.0f)) % 20) - 10))) / 5.0f) > 16.0f) {
                    tile7.name = "mountain6";
                    tile7.init();
                }
            }
        }
        biomeTiles.putAll(volcanoTiles);
        Iterator it4 = new ArrayList(mtnTiles.values()).iterator();
        while (it4.hasNext()) {
            Tile mtnTile = (Tile) it4.next();
            if (tileLevels.get(mtnTile).intValue() <= bottomLevel) {
                this.bottomMtnLayer.add(mtnTile.position);
                this.noIceHerePlease.remove(mtnTile.position);
            } else {
                Tile biomeTile = biomeTiles.get(mtnTile.position);
                if (biomeTile != null) {
                    if (mtnTile.nameUpper.equals("")) {
                        mtnTiles.put(biomeTile.position.cpy(), biomeTile);
                    } else {
                        mtnTile.name = biomeTile.name;
                        mtnTile.biome = biomeTile.biome;
                        if (mtnTile.name.contains("grass3")) {
                            mtnTile.name = "snow1";
                        } else if (mtnTile.name.contains("grass2")) {
                            mtnTile.name = "green1";
                        }
                        if (mtnTile.nameUpper.contains("ledges3") && mtnTile.biome.contains("tundra")) {
                            mtnTile.nameUpper = mtnTile.nameUpper.replace("ledges3", "ledges3snow");
                        } else if (mtnTile.nameUpper.contains("ledges3") && mtnTile.name.contains("volcano")) {
                            mtnTile.nameUpper = mtnTile.nameUpper.replace("ledges3", "ledges3volcano");
                        }
                        mtnTile.init();
                    }
                }
            }
        }
        for (Tile tile8 : mtnTiles.values()) {
            if (tile8.nameUpper.contains("ledges3") && tile8.name.equals("water2")) {
                game.map.adjustSurroundingTiles(tile8, mtnTiles, true);
            }
        }
        ledgify(mtnTiles, mtnTiles, "mountain4", "mountain3", "mountain");
        tilesToAdd.putAll(mtnTiles);
        return endPoints;
    }

    public void generateRegiDungeon(Game game, Vector2 origin) {
        HashMap<Vector2, Tile> exteriorTiles = new HashMap<>();
        ArrayList<HashMap<Vector2, Tile>> interiorTiles = new ArrayList<>();
        String[][] names = {new String[]{null, null, null, "cave2_tl_alternate", "cave2_tr_alternate", null, null, null, "cave2_tl_alternate", "cave2_tr_alternate", null, null, null}, new String[]{null, null, null, "cave2_bl", "cave2_br", null, null, null, "cave2_bl", "cave2_br", null, null, null}, new String[]{null, null, null, null, null, "cave2_tl", "cave2_up", "cave2_tr", null, null, null, null, null}, new String[]{null, null, null, null, "cave2_tl", "cave2_left", "cave2_floor", "cave2_right", "cave2_tr", null, null, null, null}, new String[]{"cave2_tl_alternate", "cave2_tr_alternate", null, "sand1", "cave2_left", "cave2_bl", "cave2_down", "cave2_br", "cave2_right", "sand1", null, "cave2_tl_alternate", "cave2_tr_alternate"}, new String[]{"cave2_bl", "cave2_br", null, "sand1", "cave2_bl", "cave2_down", "cave1_door1", "cave2_down", "cave2_br", "sand1", null, "cave2_bl", "cave2_br"}, new String[]{null, null, null, null, "sand1", "sand2", "sand2", "sand2", "sand1", null, null, null, null}, new String[]{null, null, null, null, null, "sand1", "sand1", "sand1", null, null, null, null, null}, new String[]{null, null, null, "cave2_tl_alternate", "cave2_tr_alternate", null, null, null, "cave2_tl_alternate", "cave2_tr_alternate", null, null, null}, new String[]{null, null, null, "cave2_bl", "cave2_br", null, null, null, "cave2_bl", "cave2_br", null, null, null}};
        Route currRoute = new Route("", 2);
        for (int i = 0; i < names.length; i++) {
            for (int j = 0; j < names[i].length; j++) {
                if (names[i][j] != null) {
                    Vector2 pos = new Vector2((origin.x - 96.0f) + ((float) (j * 16)), (origin.y + 80.0f) - ((float) (i * 16)));
                    exteriorTiles.put(pos, new Tile(names[i][j], pos, true, currRoute));
                }
            }
        }
        origin.add(-288.0f, 272.0f);
        for (int i2 = 0; i2 < 90; i2++) {
            interiorTiles.add(null);
        }
        HashMap<Vector2, Tile> currLayer = new HashMap<>();
        String[][] names2 = {new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_br_inner", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_bl_inner", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_right1", "cave1_br_inner", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_down1", "cave1_bl_inner", "cave1_left1", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_br_inner", "cave1_br1", "cave1_right1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_down1_dark", "cave1_down1_dark", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_left1", "cave1_bl1", "cave1_bl_inner", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_br_inner", "cave1_br1", "cave1_floor1", "cave1_floor1", "cave1_stone1", null, null, "cave1_stone1", "cave1_floor1", "cave1_floor1", "cave1_bl1", "cave1_bl_inner", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_right1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_regi1", "cave1_regi5", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_left1", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_right1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_tl1", "cave1_up1", "cave1_regipedistal1", "cave1_tr1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_left1", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_right1", "cave1_floor1", "cave1_stone1", "cave1_floor1", "cave1_left1", "cave1_floor2", "cave1_floor2", "cave1_right1", "cave1_floor1", "cave1_stone1", "cave1_floor1", "cave1_left1", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_right1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_bl1", "cave1_ramp1", "cave1_ramp1", "cave1_br1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_left1", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_right1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_left1", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_tr1", "cave1_floor1", "cave1_floor1", "cave1_stone1", "cave1_floor1", "cave1_floor1", "cave1_stone1", "cave1_floor1", "cave1_floor1", "cave1_tl1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_right1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_floor1", "cave1_left1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_up1", "cave1_up1", "cave1_up1", "cave1_up1", "cave1_entrance1", "cave1_up1", "cave1_up1", "cave1_up1", "cave1_up1", "cave1_up1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}, new String[]{"cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_right1", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2", "cave1_left1", "cave1_floor2"}};
        Route currRoute2 = new Route("regi_cave1", 44);
        for (int i3 = 0; i3 < names2.length; i3++) {
            for (int j2 = 0; j2 < names2[i3].length; j2++) {
                if (names2[i3][j2] != null) {
                    Vector2 pos2 = new Vector2(origin.x + ((float) (j2 * 16)), origin.y - ((float) (i3 * 16)));
                    Tile tile = new Tile(names2[i3][j2], pos2, true, currRoute2);
                    if (names2[i3][j2].equals("cave1_regipedistal1")) {
                        tile.items().put("REGISTEEL", 1);
                        tile.items().put("REGICE", 1);
                        tile.items().put("REGIROCK", 1);
                        tile.items().put("REGIELEKI", 1);
                        tile.items().put("REGIDRAGO", 1);
                    }
                    currLayer.put(pos2, tile);
                }
            }
        }
        interiorTiles.add(currLayer);
        for (Tile tile2 : exteriorTiles.values()) {
            Tile currTile = this.tilesToAdd.get(tile2.position);
            if (currTile == null || !currTile.nameUpper.equals("pokemon_mansion_key")) {
                this.tilesToAdd.put(tile2.position.cpy(), tile2);
            } else {
                this.tilesToAdd.put(tile2.position.cpy(), new Tile(tile2.name, currTile.nameUpper, currTile.position, true, currTile.routeBelongsTo));
            }
        }
        for (int i4 = 0; i4 < interiorTiles.size(); i4++) {
            HashMap<Vector2, Tile> currLayer2 = interiorTiles.get(i4);
            if (i4 >= this.interiorTilesToAdd.size()) {
                this.interiorTilesToAdd.add(currLayer2);
            } else if (currLayer2 != null) {
                if (this.interiorTilesToAdd.get(i4) == null) {
                    this.interiorTilesToAdd.remove(i4);
                    this.interiorTilesToAdd.add(i4, currLayer2);
                } else {
                    for (Vector2 key : currLayer2.keySet()) {
                        this.interiorTilesToAdd.get(i4).put(key, currLayer2.get(key));
                    }
                }
            }
        }
    }

    public void generateOasis(Game game, Vector2 origin) {
        Route blotchRoute = new Route("oasis1", 30);
        Tile newTile = this.tilesToAdd.get(origin);
        newTile.biome = "desert";
        int nextSize = User32.VK_PLAY + this.rand.nextInt(50);
        HashMap<Vector2, Tile> newTiles = new HashMap<>();
        ApplyBlotch(game, "oasis1", newTile, nextSize, newTiles, 0, true, blotchRoute);
        HashMap<Vector2, Tile> newTiles2 = new HashMap<>();
        ApplyBlotch(game, "pond1", newTile, nextSize / 2, newTiles2, 0, true, blotchRoute);
        Pokemon pokemon = new Pokemon("milotic", 44);
        pokemon.position = newTile.position.cpy();
        pokemon.mapTiles = game.map.overworldTiles;
        Objects.requireNonNull(pokemon);
        pokemon.standingAction = new Pokemon.Standing();
        this.pokemonToAdd.put(pokemon.position.cpy(), pokemon);
        newTiles.putAll(newTiles2);
        Iterator it = new ArrayList(newTiles.values()).iterator();
        while (it.hasNext()) {
            Tile tile2 = (Tile) it.next();
            if (tile2.nameUpper.equals("aloe_large1")) {
                newTiles.put(tile2.position.cpy().add(16.0f, 0.0f), new Tile("green1", "solid", tile2.position.cpy().add(16.0f, 0.0f), true, tile2.routeBelongsTo));
                newTiles.put(tile2.position.cpy().add(0.0f, 16.0f), new Tile("green1", "solid", tile2.position.cpy().add(0.0f, 16.0f), true, tile2.routeBelongsTo));
                newTiles.put(tile2.position.cpy().add(16.0f, 16.0f), new Tile("green1", "solid", tile2.position.cpy().add(16.0f, 16.0f), true, tile2.routeBelongsTo));
            }
        }
        ArrayList<Tile> oasisTiles = new ArrayList<>();
        for (Tile tile : newTiles.values()) {
            if (!this.mtnTiles.containsKey(tile.position)) {
                if (!tile.name.contains("water")) {
                    oasisTiles.add(tile);
                }
                this.tilesToAdd.put(tile.position.cpy(), tile);
            }
        }
        Tile newTile2 = oasisTiles.remove(this.rand.nextInt(oasisTiles.size()));
        HashMap<Vector2, Tile> exteriorTiles = new HashMap<>();
        ArrayList<HashMap<Vector2, Tile>> interiorTiles = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            interiorTiles.add(null);
        }
        HashMap<Vector2, Tile> currLayer = new HashMap<>();
        Vector2 tl2 = newTile2.position.cpy();
        String[][] names = {new String[]{"building1_wall1", "building1_wall1", "building1_wall1", "building1_wall1", "building1_wall1", "building1_wall1"}, new String[]{"building1_machine2", null, null, null, null, null}, new String[]{"building1_fossilreviver1", "building1_cables1", "building1_cables1", "building1_cables1", "building1_pokecenter1", "building1_pokecenter1_right"}, new String[]{"building1_floor2", "building1_floor1", "rug2", "building1_floor1", "building1_floor2", "building1_floor2"}};
        Route interiorRoute = new Route("fossil_lab1", 11);
        for (int i2 = 0; i2 < names.length; i2++) {
            for (int j = 0; j < names[i2].length; j++) {
                if (names[i2][j] != null) {
                    Vector2 pos2 = new Vector2((tl2.x - 96.0f) + ((float) (j * 16)), (tl2.y + 80.0f) - ((float) (i2 * 16)));
                    currLayer.put(pos2, new Tile(names[i2][j], pos2, true, interiorRoute));
                }
            }
        }
        interiorTiles.add(currLayer);
        String[][] names2 = {new String[]{"pkmnmansion_roof_NW", "pkmnmansion_roof_N", "pkmnmansion_roof_N", "pkmnmansion_roof_N_damaged", "pkmnmansion_roof_N", "pkmnmansion_roof_NE"}, new String[]{"pkmnmansion_roof_SW", "pkmnmansion_roof_S_damaged", "pkmnmansion_roof_S", "pkmnmansion_roof_S", "pkmnmansion_roof_S", "pkmnmansion_roof_SE"}, new String[]{"pkmnmansion_ext_W_window", "pkmnmansion_ext_windows", "pkmnmansion_ext_windows_W_damaged", "pkmnmansion_ext_windows_E_damaged", "pkmnmansion_ext_windows", "pkmnmansion_ext_E_window_damaged"}, new String[]{"pkmnmansion_ext_SW", "pkmnmansion_ext_S", "pkmnmansion_ext_door", "pkmnmansion_ext_S_windows_damaged", "pkmnmansion_ext_S", "pkmnmansion_ext_SE_damaged"}, new String[]{"", "", "", "", "", ""}};
        for (int i3 = 0; i3 < names2.length; i3++) {
            for (int j2 = 0; j2 < names2[i3].length; j2++) {
                if (names2[i3][j2] != null) {
                    Vector2 pos22 = new Vector2((tl2.x - 96.0f) + ((float) (j2 * 16)), (tl2.y + 80.0f) - ((float) (i3 * 16)));
                    Tile currTile = exteriorTiles.get(pos22);
                    if (currTile != null && currTile.name.equals("aloe_large1")) {
                        for (Vector2 next : new Vector2[]{new Vector2(16.0f, 0.0f), new Vector2(0.0f, 16.0f), new Vector2(16.0f, 16.0f)}) {
                            Tile nextTile = exteriorTiles.get(pos22.cpy().add(next));
                            if (nextTile.nameUpper.equals("solid")) {
                                nextTile.nameUpper = "";
                                nextTile.isSolid = false;
                            }
                        }
                    }
                    exteriorTiles.put(pos22, new Tile("sand1", names2[i3][j2], pos22, true, newTile2.routeBelongsTo));
                }
            }
        }
        for (Tile tile22 : exteriorTiles.values()) {
            Tile currTile2 = this.tilesToAdd.get(tile22.position);
            if (currTile2 == null || !currTile2.nameUpper.equals("pokemon_mansion_key")) {
                this.tilesToAdd.put(tile22.position.cpy(), tile22);
            } else {
                this.tilesToAdd.put(tile22.position.cpy(), new Tile(tile22.name, currTile2.nameUpper, currTile2.position, true, currTile2.routeBelongsTo));
            }
        }
        for (int i4 = 0; i4 < interiorTiles.size(); i4++) {
            HashMap<Vector2, Tile> currLayer2 = interiorTiles.get(i4);
            if (i4 >= this.interiorTilesToAdd.size()) {
                this.interiorTilesToAdd.add(currLayer2);
            } else if (currLayer2 != null) {
                if (this.interiorTilesToAdd.get(i4) == null) {
                    this.interiorTilesToAdd.remove(i4);
                    this.interiorTilesToAdd.add(i4, currLayer2);
                } else {
                    for (Vector2 key : currLayer2.keySet()) {
                        this.interiorTilesToAdd.get(i4).put(key, currLayer2.get(key));
                    }
                }
            }
        }
    }

    public void generateDesertRuins(Game game, Vector2 origin) {
        Route currRoute = new Route("ruins1_outer", 25);
        Tile newTile = this.tilesToAdd.get(origin);
        HashMap<Vector2, Tile> newTiles = new HashMap<>();
        HashMap<Vector2, Tile> newTiles2 = new HashMap<>();
        ApplyBlotch(game, "ruins1_upper2", newTile, 230, newTiles2, 0, false, currRoute);
        newTiles.putAll(newTiles2);
        newTiles2.clear();
        ApplyBlotch(game, "ruins1_upper", newTile, 240, newTiles2, 0, false, currRoute);
        newTiles.putAll(newTiles2);
        for (Tile tile : newTiles.values()) {
            if (tile.name.contains("ruins1")) {
                game.map.adjustSurroundingTiles(tile, newTiles);
            }
        }
        for (Tile tile2 : newTiles.values()) {
            if (!this.mtnTiles.containsKey(tile2.position)) {
                this.tilesToAdd.put(tile2.position.cpy(), tile2);
            }
        }
        for (int i = -1; i < 2; i++) {
            for (int j = -1; j < 2; j++) {
                Tile currTile = this.tilesToAdd.get(newTile.position.cpy().add((float) (16 * i), (float) (16 * j)));
                if (!currTile.name.equals("desert4")) {
                    this.tilesToAdd.put(currTile.position.cpy(), new Tile("ruins_floor2", currTile.position.cpy(), true, (Route) null));
                }
            }
        }
        Vector2[] positions2 = {newTile.position.cpy().add(-32.0f, 16.0f), newTile.position.cpy().add(32.0f, 16.0f), newTile.position.cpy().add(-32.0f, -16.0f), newTile.position.cpy().add(32.0f, -16.0f)};
        for (Vector2 position : positions2) {
            if (this.rand.nextInt(3) > 0) {
                this.tilesToAdd.put(position.cpy(), new Tile("ruins1_pillar1", position.cpy(), true, (Route) null));
            }
        }
        this.tilesToAdd.put(newTile.position.cpy(), new Tile("ruins1_NSEW", "stairs_down2", newTile.position.cpy(), true, currRoute));
        generateRuinsInterior(newTile.position.cpy());
    }

    public void generateRuinsInterior(Vector2 origin) {
        Tile newTile;
        String[][] names = {new String[]{"ruins2_wall1", "ruins2_wall1", "ruins2_wall1", "ruins2_wall1", "ruins2_wall1", "ruins2_wall1", "ruins2_wall1", "ruins2_wall1", "ruins2_wall1"}, new String[]{"ruins2_wall1", "ruins2_wall1", "ruins2_wall1", "ruins2_volcarona_picture1", null, null, "ruins2_wall1", "ruins2_wall1", "ruins2_wall1"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "pedistal1", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "pedistal1", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "pedistal1", "ruins2_path1", "blank1", "blank1", "pedistal1", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins1_pillar1", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins1_pillar1", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins1_pillar1", "ruins2_path1", "blank1", "blank1", "ruins1_pillar1", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins1_pillar1", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins1_pillar1", "ruins_floor2"}, new String[]{"ruins_floor2", "ruins_floor2", "ruins_floor2", "ruins2_path1", "blank1", "blank1", "ruins_floor2", "ruins_floor2", "ruins_floor2"}, new String[]{null, null, null, "ruins2_path1", "ruins_floor2_stairs", "blank1", null, null, null, null}};
        ArrayList<HashMap<Vector2, Tile>> interiorTiles = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            interiorTiles.add(new HashMap<>());
        }
        Vector2 startLoc = new Vector2(10.0f, 10.0f);
        Vector2 bl = origin.add(-496.0f, -496.0f);
        ArrayList<Vector2> startLocs = new ArrayList<>();
        ArrayList<Vector2> endPoints = new ArrayList<>();
        ArrayList<Vector2> dusclopsPositions = new ArrayList<>();
        endPoints.add(startLoc);
        Route currRoute = new Route("ruins1_inner", 22);
        for (int levelNum = interiorTiles.size() - 1; levelNum >= 0; levelNum--) {
            HashMap<Vector2, Tile> currLayer = interiorTiles.get(levelNum);
            if (levelNum == 0) {
                for (int i2 = 0; i2 < names.length; i2++) {
                    for (int j = 0; j < names[i2].length; j++) {
                        if (names[i2][j] != null) {
                            Vector2 startPos = endPoints.get(0);
                            Vector2 position = bl.cpy().add((((startPos.x * 3.0f) - 3.0f) + ((float) j)) * 16.0f, (((startPos.y * 3.0f) + 17.0f) - ((float) i2)) * 16.0f);
                            if (names[i2][j].equals("ruins_floor2_stairs")) {
                                newTile = new Tile("blank1", "stairs_up1", position.cpy(), true, currRoute);
                            } else if (names[i2][j].equals("pedistal1")) {
                                newTile = new Tile("ruins_floor2", "pedistal1", position.cpy(), true, currRoute);
                            } else {
                                newTile = new Tile(names[i2][j], position.cpy(), true, currRoute);
                            }
                            if (names[i2][j].contains("pillar")) {
                                newTile.items().put("torch", 1);
                            }
                            if (i2 == 2 && j == 4) {
                                newTile.nameUpper = "volcarona";
                            }
                            currLayer.put(position, newTile);
                        }
                    }
                }
            } else {
                float complexity = 15.0f;
                Iterator<Vector2> it = endPoints.iterator();
                while (it.hasNext()) {
                    Vector2 position2 = it.next();
                    String nameUpper = "stairs_up1";
                    if (levelNum == interiorTiles.size() - 1) {
                        nameUpper = "stairs_up1_exit";
                    }
                    currLayer.put(bl.cpy().add(((position2.x * 3.0f) + 1.0f) * 16.0f, ((position2.y * 3.0f) + 1.0f) * 16.0f), new Tile("desert4", nameUpper, bl.cpy().add(((position2.x * 3.0f) + 1.0f) * 16.0f, ((position2.y * 3.0f) + 1.0f) * 16.0f), true, currRoute));
                    startLocs.add(position2);
                    startLocs.add(position2);
                    if (this.rand.nextInt(2) == 0 || levelNum == interiorTiles.size() - 1) {
                        startLocs.add(position2);
                        if (levelNum != interiorTiles.size() - 1) {
                            complexity = 10.0f;
                        }
                    }
                }
                endPoints.clear();
                boolean[][] maze = GenForest2.Maze_Algo3(20, 20, complexity, (float) startLocs.size(), this.rand, startLocs);
                System.out.print("\n");
                System.out.print("\n");
                for (int j2 = maze.length - 1; j2 >= 0; j2--) {
                    for (int i3 = 0; i3 < maze[j2].length; i3++) {
                        System.out.print(String.valueOf(maze[i3][j2] ? 1 : " ") + " ");
                    }
                    System.out.print("\n");
                }
                dusclopsPositions.clear();
                for (int i4 = 0; i4 < maze.length; i4++) {
                    for (int j3 = 0; j3 < maze[i4].length; j3++) {
                        if (maze[i4][j3]) {
                            for (int k = 0; k < 3; k++) {
                                for (int l = 0; l < 4; l++) {
                                    Vector2 position3 = bl.cpy().add((float) (((i4 * 3) + k) * 16), (float) (((j3 * 3) + l) * 16));
                                    Tile currTile = currLayer.get(position3);
                                    if (currTile == null || currTile.name.contains("wall")) {
                                        if (l == 3) {
                                            Tile newTile2 = new Tile("ruins2_wall1", position3.cpy(), true, (Route) null);
                                            if (levelNum != interiorTiles.size() - 1 && i4 % 2 == 0 && k == 1 && this.rand.nextInt(4) > 0) {
                                                newTile2.items().put("torch", 1);
                                            }
                                            currLayer.put(position3, newTile2);
                                        } else {
                                            String name = "desert4";
                                            if (levelNum == interiorTiles.size() - 1) {
                                                name = "desert4_isGrass";
                                                int offset = Math.abs((((i4 * 3) + k) % 12) - 6) + Math.abs((((j3 * 3) + l) % 12) - 6);
                                                if (this.rand.nextInt(offset + 1) + offset > 14) {
                                                    name = "ruins_floor2";
                                                }
                                            } else if (levelNum == interiorTiles.size() - 2) {
                                                name = "desert4_isGrass";
                                                int offset2 = Math.abs((((i4 * 3) + k) % 12) - 6) + Math.abs((((j3 * 3) + l) % 12) - 6);
                                                if (this.rand.nextInt(offset2 + 1) + offset2 > 10) {
                                                    name = "ruins_floor2";
                                                }
                                            } else if (levelNum == interiorTiles.size() - 3) {
                                                int offset3 = Math.abs((((i4 * 3) + k) % 12) - 6) + Math.abs((((j3 * 3) + l) % 12) - 6);
                                                if (this.rand.nextInt(offset3 + 1) + offset3 > 7) {
                                                    name = "ruins_floor2";
                                                }
                                            } else {
                                                name = "ruins_floor2";
                                            }
                                            currLayer.put(position3, new Tile(name, position3.cpy(), true, currRoute));
                                        }
                                        if (levelNum < 3 && k == 1 && l == 1 && i4 % 3 == 0 && j3 % 3 == 0) {
                                            dusclopsPositions.add(position3);
                                        }
                                    }
                                }
                            }
                            if (!startLocs.contains(new Vector2((float) i4, (float) j3)) && i4 % 2 == 0 && j3 % 2 == 0 && this.rand.nextInt(3) == 0) {
                                ArrayList<Vector2> potPositions = new ArrayList<>();
                                if (j3 - 1 >= 0 && !maze[i4][j3 - 1]) {
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 0) * 16), (float) (((j3 * 3) + 0) * 16)));
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 1) * 16), (float) (((j3 * 3) + 0) * 16)));
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 2) * 16), (float) (((j3 * 3) + 0) * 16)));
                                }
                                if (j3 + 1 < 20 && !maze[i4][j3 + 1]) {
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 0) * 16), (float) (((j3 * 3) + 2) * 16)));
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 1) * 16), (float) (((j3 * 3) + 2) * 16)));
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 2) * 16), (float) (((j3 * 3) + 2) * 16)));
                                }
                                if (i4 + 1 < 20 && !maze[i4 + 1][j3]) {
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 2) * 16), (float) (((j3 * 3) + 0) * 16)));
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 2) * 16), (float) (((j3 * 3) + 1) * 16)));
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 2) * 16), (float) (((j3 * 3) + 2) * 16)));
                                }
                                if (i4 - 1 >= 0 && !maze[i4 - 1][j3]) {
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 0) * 16), (float) (((j3 * 3) + 0) * 16)));
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 0) * 16), (float) (((j3 * 3) + 1) * 16)));
                                    potPositions.add(bl.cpy().add((float) (((i4 * 3) + 0) * 16), (float) (((j3 * 3) + 2) * 16)));
                                }
                                Iterator<Vector2> it2 = potPositions.iterator();
                                while (it2.hasNext()) {
                                    Vector2 position4 = it2.next();
                                    if (this.rand.nextInt(7) > 3) {
                                        Tile tile = currLayer.get(position4);
                                        tile.nameUpper = "pot1";
                                        tile.init(tile.name, tile.nameUpper, tile.position, true, tile.routeBelongsTo);
                                    }
                                }
                            } else if (levelNum == 1 && i4 % 2 == 0 && j3 % 2 == 0 && this.rand.nextInt(2) == 0) {
                                Tile tile2 = currLayer.get(bl.cpy().add((float) (((i4 * 3) + 1) * 16), (float) (((j3 * 3) + 1) * 16)));
                                if (tile2.nameUpper.equals("")) {
                                    tile2.nameUpper = "ruins_statue1";
                                    tile2.init(tile2.name, tile2.nameUpper, tile2.position, true, tile2.routeBelongsTo);
                                }
                            }
                        }
                    }
                }
                int size = dusclopsPositions.size();
                int i5 = 0;
                while (i5 < 2 + this.rand.nextInt(3) && i5 < size) {
                    Vector2 position5 = dusclopsPositions.remove(this.rand.nextInt(dusclopsPositions.size()));
                    Pokemon pokemon = new Pokemon("dusclops", 44, Pokemon.Generation.CRYSTAL);
                    pokemon.position = position5.cpy();
                    Objects.requireNonNull(pokemon);
                    pokemon.standingAction = new Pokemon.Standing();
                    pokemon.aggroPlayer = true;
                    this.interiorPokemon.put(pokemon, Integer.valueOf((levelNum + 100) - 5));
                    i5++;
                }
                int size2 = startLocs.size();
                int numStairs = 2;
                if (levelNum == 1) {
                    numStairs = 1;
                }
                for (int i6 = 0; i6 < size2; i6++) {
                    Vector2 startLoc2 = startLocs.remove(this.rand.nextInt(startLocs.size()));
                    System.out.println(startLoc2);
                    if (i6 < numStairs) {
                        for (int k2 = 0; k2 < 3; k2++) {
                            for (int l2 = 0; l2 < 3; l2++) {
                                Vector2 position6 = bl.cpy().add(((startLoc2.x * 3.0f) + ((float) k2)) * 16.0f, ((startLoc2.y * 3.0f) + ((float) l2)) * 16.0f);
                                if (k2 == 1 && l2 == 1) {
                                    currLayer.put(position6.cpy(), new Tile("ruins_floor2", "stairs_down2", position6.cpy(), true, currRoute));
                                } else if (this.rand.nextInt(5) > 1) {
                                    currLayer.put(position6.cpy(), new Tile("ruins_floor2", position6.cpy(), true, currRoute));
                                } else {
                                    currLayer.put(position6.cpy(), new Tile("desert4", position6.cpy(), true, currRoute));
                                }
                            }
                        }
                        endPoints.add(startLoc2);
                    } else {
                        int numPots = 0;
                        for (int k3 = 0; k3 < 3; k3++) {
                            for (int l3 = 0; l3 < 3; l3++) {
                                Vector2 position7 = bl.cpy().add(((startLoc2.x * 3.0f) + ((float) k3)) * 16.0f, ((startLoc2.y * 3.0f) + ((float) l3)) * 16.0f);
                                Tile tile3 = currLayer.get(position7);
                                if (k3 == 1 && l3 == 1) {
                                    if (tile3 != null && !tile3.nameUpper.contains("stairs")) {
                                        tile3.nameUpper = "pokeball1";
                                        tile3.init(tile3.name, tile3.nameUpper, tile3.position, true, tile3.routeBelongsTo);
                                        if (this.rand.nextInt(2) == 0) {
                                            tile3.hasItem = "ultra ball";
                                            tile3.hasItemAmount = 2;
                                        } else {
                                            tile3.hasItem = "ancientpowder";
                                            tile3.hasItemAmount = this.rand.nextInt(3) + 2;
                                        }
                                    }
                                } else if (this.rand.nextInt(7) > 3 && numPots < 2) {
                                    currLayer.put(position7.cpy(), new Tile(tile3.name, "pot1", position7.cpy(), true, currRoute));
                                    numPots++;
                                }
                            }
                        }
                    }
                }
                startLocs.clear();
            }
        }
        interiorTiles.add(new HashMap<>());
        for (int i7 = 0; i7 < interiorTiles.size(); i7++) {
            HashMap<Vector2, Tile> currLayer2 = interiorTiles.get(i7);
            int interiorIndex = (i7 + 100) - 5;
            if (interiorIndex >= this.interiorTilesToAdd.size()) {
                this.interiorTilesToAdd.add(currLayer2);
            } else if (this.interiorTilesToAdd.get(interiorIndex) == null) {
                this.interiorTilesToAdd.remove(interiorIndex);
                this.interiorTilesToAdd.add(interiorIndex, currLayer2);
            } else {
                for (Vector2 key : currLayer2.keySet()) {
                    this.interiorTilesToAdd.get(interiorIndex).put(key, currLayer2.get(key));
                }
            }
        }
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: CFG modification limit reached, blocks count: 1379
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:66)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:44)
        */
    public void generateMansion(Game r12, HashMap<Vector2, com.corona.game.Tile> r13, ArrayList<HashMap<Vector2, com.corona.game.Tile>> r14, Vector2 r15) {
        /*
        // Method dump skipped, instructions count: 12684
        */
        throw new UnsupportedOperationException("Method not decompiled: com.corona.game.GenIsland1.generateMansion(com.corona.Game, java.util.HashMap, java.util.ArrayList, com.badlogic.gdx.math.Vector2):void");
    }

    public boolean isPathBetween(HashMap<Vector2, Tile> currLayer, Tile tileA, Tile tileB) {
        ArrayList<Tile> checkTiles = new ArrayList<>();
        ArrayList<Vector2> alreadyChecked = new ArrayList<>();
        checkTiles.add(tileA);
        while (checkTiles.size() > 0) {
            Tile tile = checkTiles.remove(0);
            if (tile != null && tile.position.equals(tileB.position)) {
                return true;
            }
            if (tile != tileA) {
                if (tile != null && (!tile.isSolid || tile.nameUpper.contains("pokeball"))) {
                    if (alreadyChecked.contains(tile.position)) {
                    }
                }
            }
            alreadyChecked.add(tile.position);
            checkTiles.add(currLayer.get(tile.position.cpy().add(-16.0f, 0.0f)));
            checkTiles.add(currLayer.get(tile.position.cpy().add(16.0f, 0.0f)));
            checkTiles.add(currLayer.get(tile.position.cpy().add(0.0f, -16.0f)));
            checkTiles.add(currLayer.get(tile.position.cpy().add(0.0f, 16.0f)));
        }
        return false;
    }

    public void ledgify(HashMap<Vector2, Tile> tilesToAdd, HashMap<Vector2, Tile> nextIslandTiles, String tileType, String replaceWith, String biome) {
        ledgify(tilesToAdd, nextIslandTiles, tileType, replaceWith, biome, "black1");
    }

    public boolean riverContains(Vector2 position) {
        Vector2 rotate = position.cpy().rotateDeg(-((float) Math.toDegrees(Math.atan((double) (position.x / position.y)))));
        float offset3 = ((float) Math.sin((double) (rotate.x / (60.0f * 4.0f)))) * 4.0f;
        float offset1 = ((float) Math.abs(Math.floorMod((int) ((rotate.y / 60.0f) - offset3), 14) - 7)) * 2.0f;
        if (offset1 * 5.0f * ((float) Math.abs(Math.floorMod((int) ((rotate.y / 60.0f) - offset3), 20) - 10)) * 2.0f > ((float) 850)) {
            return true;
        }
        return false;
    }

    public void ledgify(HashMap<Vector2, Tile> tilesToAdd, HashMap<Vector2, Tile> nextIslandTiles, String tileType, String replaceWith, String biome, String nullType) {
        boolean done = false;
        String ledgeType = "ledges3";
        if (tileType.contains("volcano")) {
            ledgeType = "ledges3volcano";
        }
        while (!done) {
            done = true;
            for (Tile tile : nextIslandTiles.values()) {
                if (tile.name.equals(tileType)) {
                    Tile bl = tilesToAdd.get(tile.position.cpy().add(-16.0f, -16.0f));
                    Tile bot = tilesToAdd.get(tile.position.cpy().add(0.0f, -16.0f));
                    Tile br = tilesToAdd.get(tile.position.cpy().add(16.0f, -16.0f));
                    Tile left = tilesToAdd.get(tile.position.cpy().add(-16.0f, 0.0f));
                    Tile tl = tilesToAdd.get(tile.position.cpy().add(-16.0f, 16.0f));
                    Tile top = tilesToAdd.get(tile.position.cpy().add(0.0f, 16.0f));
                    Tile tr = tilesToAdd.get(tile.position.cpy().add(16.0f, 16.0f));
                    Tile right = tilesToAdd.get(tile.position.cpy().add(16.0f, 0.0f));
                    if (bl == null) {
                        bl = new Tile(nullType, tile.position.cpy());
                    }
                    if (bot == null) {
                        bot = new Tile(nullType, tile.position.cpy());
                    }
                    if (br == null) {
                        br = new Tile(nullType, tile.position.cpy());
                    }
                    if (left == null) {
                        left = new Tile(nullType, tile.position.cpy());
                    }
                    if (tl == null) {
                        tl = new Tile(nullType, tile.position.cpy());
                    }
                    if (top == null) {
                        top = new Tile(nullType, tile.position.cpy());
                    }
                    if (tr == null) {
                        tr = new Tile(nullType, tile.position.cpy());
                    }
                    if (right == null) {
                        right = new Tile(nullType, tile.position.cpy());
                    }
                    Tile newTile = tilesToAdd.get(tile.position);
                    if (newTile == null || newTile.name.equals(tileType)) {
                        if (!left.name.equals(tileType) && !right.name.equals(tileType)) {
                            Tile newTile2 = new Tile(replaceWith, tile.position.cpy());
                            newTile2.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile2);
                            nextIslandTiles.put(tile.position.cpy(), newTile2);
                            done = false;
                        }
                        if (!top.name.equals(tileType) && !bot.name.equals(tileType)) {
                            Tile newTile3 = new Tile(replaceWith, tile.position.cpy());
                            newTile3.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile3);
                            nextIslandTiles.put(tile.position.cpy(), newTile3);
                            done = false;
                        }
                        if (!top.name.equals(tileType) && !left.name.equals(tileType) && !br.name.equals(tileType)) {
                            Tile newTile4 = new Tile(replaceWith, tile.position.cpy());
                            newTile4.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile4);
                            nextIslandTiles.put(tile.position.cpy(), newTile4);
                            done = false;
                        }
                        if (!top.name.equals(tileType) && !right.name.equals(tileType) && !bl.name.equals(tileType)) {
                            Tile newTile5 = new Tile(replaceWith, tile.position.cpy());
                            newTile5.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile5);
                            nextIslandTiles.put(tile.position.cpy(), newTile5);
                            done = false;
                        }
                        if (!bot.name.equals(tileType) && !right.name.equals(tileType) && !tl.name.equals(tileType)) {
                            Tile newTile6 = new Tile(replaceWith, tile.position.cpy());
                            newTile6.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile6);
                            nextIslandTiles.put(tile.position.cpy(), newTile6);
                            done = false;
                        }
                        if (!bot.name.equals(tileType) && !left.name.equals(tileType) && !tr.name.equals(tileType)) {
                            Tile newTile7 = new Tile(replaceWith, tile.position.cpy());
                            newTile7.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile7);
                            nextIslandTiles.put(tile.position.cpy(), newTile7);
                            done = false;
                        }
                        if (bot.name.equals(tileType) && !left.name.equals(tileType) && !br.name.equals(tileType)) {
                            Tile newTile8 = new Tile(replaceWith, tile.position.cpy());
                            newTile8.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile8);
                            nextIslandTiles.put(tile.position.cpy(), newTile8);
                            done = false;
                        }
                        if (bot.name.equals(tileType) && !right.name.equals(tileType) && !bl.name.equals(tileType)) {
                            Tile newTile9 = new Tile(replaceWith, tile.position.cpy());
                            newTile9.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile9);
                            nextIslandTiles.put(tile.position.cpy(), newTile9);
                            done = false;
                        }
                        if (top.name.equals(tileType) && !left.name.equals(tileType) && !tr.name.equals(tileType)) {
                            Tile newTile10 = new Tile(replaceWith, tile.position.cpy());
                            newTile10.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile10);
                            nextIslandTiles.put(tile.position.cpy(), newTile10);
                            done = false;
                        }
                        if (top.name.equals(tileType) && !right.name.equals(tileType) && !tl.name.equals(tileType)) {
                            Tile newTile11 = new Tile(replaceWith, tile.position.cpy());
                            newTile11.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile11);
                            nextIslandTiles.put(tile.position.cpy(), newTile11);
                            done = false;
                        }
                        if (right.name.equals(tileType) && !top.name.equals(tileType) && !br.name.equals(tileType)) {
                            Tile newTile12 = new Tile(replaceWith, tile.position.cpy());
                            newTile12.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile12);
                            nextIslandTiles.put(tile.position.cpy(), newTile12);
                            done = false;
                        }
                        if (right.name.equals(tileType) && !bot.name.equals(tileType) && !tr.name.equals(tileType)) {
                            Tile newTile13 = new Tile(replaceWith, tile.position.cpy());
                            newTile13.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile13);
                            nextIslandTiles.put(tile.position.cpy(), newTile13);
                            done = false;
                        }
                        if (left.name.equals(tileType) && !bot.name.equals(tileType) && !tl.name.equals(tileType)) {
                            Tile newTile14 = new Tile(replaceWith, tile.position.cpy());
                            newTile14.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile14);
                            nextIslandTiles.put(tile.position.cpy(), newTile14);
                            done = false;
                        }
                        if (left.name.equals(tileType) && !top.name.equals(tileType) && !bl.name.equals(tileType)) {
                            Tile newTile15 = new Tile(replaceWith, tile.position.cpy());
                            newTile15.biome = biome;
                            tilesToAdd.put(tile.position.cpy(), newTile15);
                            nextIslandTiles.put(tile.position.cpy(), newTile15);
                            done = false;
                        }
                    }
                }
            }
        }
        for (Tile tile2 : nextIslandTiles.values()) {
            Tile bl2 = tilesToAdd.get(tile2.position.cpy().add(-16.0f, -16.0f));
            Tile down = tilesToAdd.get(tile2.position.cpy().add(0.0f, -16.0f));
            Tile br2 = tilesToAdd.get(tile2.position.cpy().add(16.0f, -16.0f));
            Tile left2 = tilesToAdd.get(tile2.position.cpy().add(-16.0f, 0.0f));
            Tile tl2 = tilesToAdd.get(tile2.position.cpy().add(-16.0f, 16.0f));
            Tile up = tilesToAdd.get(tile2.position.cpy().add(0.0f, 16.0f));
            Tile tr2 = tilesToAdd.get(tile2.position.cpy().add(16.0f, 16.0f));
            Tile right2 = tilesToAdd.get(tile2.position.cpy().add(16.0f, 0.0f));
            Tile tile3 = tilesToAdd.get(tile2.position);
            if (tile3 != null && tile3.name.equals(tileType)) {
                if (bl2 == null) {
                    bl2 = new Tile(nullType, tile3.position.cpy());
                }
                if (down == null) {
                    down = new Tile(nullType, tile3.position.cpy());
                }
                if (br2 == null) {
                    br2 = new Tile(nullType, tile3.position.cpy());
                }
                if (left2 == null) {
                    left2 = new Tile(nullType, tile3.position.cpy());
                }
                if (tl2 == null) {
                    tl2 = new Tile(nullType, tile3.position.cpy());
                }
                if (up == null) {
                    up = new Tile(nullType, tile3.position.cpy());
                }
                if (tr2 == null) {
                    tr2 = new Tile(nullType, tile3.position.cpy());
                }
                if (right2 == null) {
                    right2 = new Tile(nullType, tile3.position.cpy());
                }
                if (left2.name.equals(tileType) && !down.name.equals(tileType) && right2.name.equals(tileType)) {
                    Tile newTile16 = new Tile(tileType, ledgeType + "_N", tile3.position.cpy());
                    newTile16.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile16);
                } else if (up.name.equals(tileType) && right2.name.equals(tileType) && !down.name.equals(tileType) && !left2.name.equals(tileType)) {
                    Tile newTile17 = new Tile(tileType, ledgeType + "_NE", tile3.position.cpy());
                    newTile17.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile17);
                } else if (up.name.equals(tileType) && !left2.name.equals(tileType) && down.name.equals(tileType)) {
                    Tile newTile18 = new Tile(tileType, ledgeType + "_E", tile3.position.cpy());
                    newTile18.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile18);
                } else if (!up.name.equals(tileType) && !left2.name.equals(tileType) && right2.name.equals(tileType) && down.name.equals(tileType)) {
                    Tile newTile19 = new Tile(tileType, ledgeType + "_SE", tile3.position.cpy());
                    newTile19.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile19);
                } else if (!up.name.equals(tileType) && left2.name.equals(tileType) && right2.name.equals(tileType)) {
                    Tile newTile20 = new Tile(tileType, ledgeType + "_S", tile3.position.cpy());
                    newTile20.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile20);
                } else if (!up.name.equals(tileType) && down.name.equals(tileType) && left2.name.equals(tileType) && !right2.name.equals(tileType)) {
                    Tile newTile21 = new Tile(tileType, ledgeType + "_SW", tile3.position.cpy());
                    newTile21.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile21);
                } else if (up.name.equals(tileType) && down.name.equals(tileType) && !right2.name.equals(tileType)) {
                    Tile newTile22 = new Tile(tileType, ledgeType + "_W", tile3.position.cpy());
                    newTile22.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile22);
                } else if (up.name.equals(tileType) && left2.name.equals(tileType) && !down.name.equals(tileType) && !right2.name.equals(tileType)) {
                    Tile newTile23 = new Tile(tileType, ledgeType + "_NW", tile3.position.cpy());
                    newTile23.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile23);
                } else if (!br2.name.equals(tileType) && down.name.equals(tileType) && right2.name.equals(tileType)) {
                    Tile newTile24 = new Tile(tileType, ledgeType + "_NW_inner", tile3.position.cpy());
                    newTile24.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile24);
                } else if (!bl2.name.equals(tileType) && down.name.equals(tileType) && left2.name.equals(tileType)) {
                    Tile newTile25 = new Tile(tileType, ledgeType + "_NE_inner", tile3.position.cpy());
                    newTile25.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile25);
                } else if (!tr2.name.equals(tileType) && up.name.equals(tileType) && right2.name.equals(tileType)) {
                    Tile newTile26 = new Tile(tileType, ledgeType + "_SW_inner", tile3.position.cpy());
                    newTile26.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile26);
                } else if (!tl2.name.equals(tileType) && up.name.equals(tileType) && left2.name.equals(tileType)) {
                    Tile newTile27 = new Tile(tileType, ledgeType + "_SE_inner", tile3.position.cpy());
                    newTile27.biome = biome;
                    tilesToAdd.put(tile3.position.cpy(), newTile27);
                }
            }
        }
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        game.map.tiles.putAll(this.tilesToAdd);
        this.tilesToAdd.clear();
        for (int i = 0; i < this.interiorTilesToAdd.size(); i++) {
            if (this.interiorTilesToAdd.get(i) != null) {
                if (game.map.interiorTiles.get(i) == null) {
                    game.map.interiorTiles.remove(i);
                    game.map.interiorTiles.add(i, new HashMap<>());
                }
                System.out.println(i);
                game.map.interiorTiles.get(i).putAll(this.interiorTilesToAdd.get(i));
            }
        }
        this.interiorTilesToAdd.clear();
        for (Pokemon pokemon : this.pokemonToAdd.values()) {
            game.insertAction(pokemon.standingAction);
            if (pokemon.specie.name.contains("nido") && pokemon.gender.equals("female")) {
                game.map.tiles.put(pokemon.position.cpy(), new Tile("mountain3", pokemon.position.cpy(), true));
            } else if (pokemon.specie.name.equals("charizard") && pokemon.gender.equals("female")) {
                game.map.tiles.put(pokemon.position.cpy(), new Tile("green1", "campfire1", pokemon.position.cpy(), true));
            }
        }
        this.pokemonToAdd.clear();
        for (Pokemon pokemon2 : this.interiorPokemon.keySet()) {
            if (!game.map.pokemon.containsKey(pokemon2.position)) {
                int interiorIndex = this.interiorPokemon.get(pokemon2).intValue();
                game.insertAction(pokemon2.standingAction);
                pokemon2.mapTiles = game.map.interiorTiles.get(interiorIndex);
                pokemon2.interiorIndex = interiorIndex;
                game.map.pokemon.put(pokemon2.position.cpy(), pokemon2);
            }
        }
        this.interiorPokemon.clear();
        Iterator<Vector2> it = this.trapinchSpawns.iterator();
        while (it.hasNext()) {
            Vector2 position = it.next();
            Tile tile = game.map.overworldTiles.get(position);
            if (tile != null && tile.name.equals("desert2")) {
                Pokemon trapinch = new Pokemon("trapinch", 22, Pokemon.Generation.CRYSTAL);
                trapinch.mapTiles = game.map.overworldTiles;
                trapinch.position = position.cpy();
                trapinch.isTrapping = true;
                Objects.requireNonNull(trapinch);
                game.insertAction(new Pokemon.Burrowed());
                tile.items().put("trapinch", 1);
            }
        }
        this.trapinchSpawns.clear();
        if (!this.tilesToAdd.isEmpty()) {
            return;
        }
        if (this.doActions.isEmpty()) {
            game.actionStack.remove(this);
            Iterator<Tile> it2 = this.edges.iterator();
            while (it2.hasNext()) {
                game.map.edges.add(it2.next().position.cpy());
            }
            Vector2 startLoc = this.edges.get(game.map.rand.nextInt(this.edges.size())).position;
            game.map.bottomLeft = this.bottomLeft;
            game.map.topRight = this.topRight;
            game.player.position.set(startLoc);
            game.player.spawnLoc.set(startLoc);
            game.player.spawnIndex = -1;
            game.cam.position.set(startLoc.x + 16.0f, startLoc.y, 0.0f);
            return;
        }
        Action currAction = this.doActions.get(0);
        this.doActions.remove(0);
        game.insertAction(currAction);
        game.actionStack.remove(this);
    }
}
